-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate contracts v2.2.0 #1845
base: integration-oasis
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments
src/@types/NFTFactory.ts
Outdated
export interface AccessListData { | ||
name: string | ||
symbol: string | ||
tokenURI: string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a typing as NftCreateData
is used when creating a NFT.
src/contracts/AccessList.ts
Outdated
@@ -41,6 +39,33 @@ export class AccessListContract extends SmartContract { | |||
return await accessListContract.tokenURI() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no function tokenURI without params, so this will never work
src/contracts/AccessList.ts
Outdated
const accessListContract = this.getContract(accessListAddress) | ||
return await accessListContract.symbol() | ||
} | ||
|
||
/** | ||
* Mint ERC721 contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mint new token, or add address to accesslist
it's not minting another erc721 contract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll modify
src/contracts/AccessList.ts
Outdated
@@ -99,6 +124,13 @@ export class AccessListContract extends SmartContract { | |||
return <ReceiptOrEstimate<G>>trxReceipt | |||
} | |||
|
|||
/** | |||
* Burn Access List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete address from accessList or burn tokenId
src/contracts/AccessListFactory.ts
Outdated
* @return {Promise<string|BigNumber>} The transaction hash or the gas estimate. | ||
*/ | ||
public async deployAccessListContract<G extends boolean = false>( | ||
listData: AccessListData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advice you to delete that typing (AccessListData) and use function params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sure.
@@ -70,22 +74,32 @@ export class Nft extends SmartContract { | |||
) | |||
if (estimateGas) return <G extends false ? string : BigNumber>estGas | |||
|
|||
const addresses = [minter, paymentCollector, mpFeeAddress, feeToken] | |||
if (accessListContract) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only templateID == 4 supports accessLists , so pls make sure that we don't pass it to other template, because those templates might use those fields for something else
providerUrl | ||
) | ||
assert(grapqlOrderTx, 'Ordering graphql dataset failed.') | ||
// arwaveOrderTx = await orderAsset( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why did we removed this tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have commented them for debug because these were failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, you commented the order , but left the downloads on next tests :) and those are failing without orders..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can focus on this problem, now since I am blocked on testing the integration side.
test/config.ts
Outdated
@@ -48,3 +48,16 @@ export const getAddresses = () => { | |||
) | |||
return data.development | |||
} | |||
|
|||
export const getAddressesForSapphire = (testnet: boolean) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's a good ideea to have two functions:
- getAddressesForChain(chainID)
- getAddressesForSapphire which calls getAddressesForChain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have that locally, not pushed yet.
why for every call to accesslist functions do i need to provide accessListAddress ? just have it in the constructor and do something like:
|
It wasn't a specific preference, I can change that AccessList class to extend SmartContractWithAddress class and store the address in constructor. The only reason for using this approach is that Nft class has in each method nft address passed as parameter. |
The integration tests for ordering different types of assets is an older issue which pops up due to exceeded timeout. I commented the assets which rely on external services such as ipfs and create an issue for fixing those tests in the future since they are not impacted by this PR changes. Issue created for ipfs which is the only one impacting the tests due to invalid CID: #1849 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the sapphire integration tests in a folder called scripts
? Seems like it would be better placed in /test/integration/
.gitignore
Outdated
test/**/*.js | ||
test/unit/*.js | ||
test/integration/*.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you done this? Before we ignored all javascript files in the test directory, now you want only to ignore js files if they are in either /test/unit
or test/integration
? I don't see any benefit to changing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was when I created a .js file, I'll correct it now since I have the .ts script, not .js
README.md
Outdated
@@ -128,6 +128,21 @@ npm run test:integration | |||
npm run test:integration:cover | |||
``` | |||
|
|||
### Sapphire Integration Tests | |||
|
|||
Currently, there is used Oasis Sapphire Test network, please export the `PRIVATE_KEY` before testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is worded poorly, I think what you are trying to say is:
Currently, there is used Oasis Sapphire Test network, please export the `PRIVATE_KEY` before testing. | |
We are currently using the live Oasis Sapphire Test network for the integration tests. Please export the `PRIVATE_KEY` before running the tests. |
const provider = sapphire.wrap( | ||
ethers.getDefaultProvider(sapphire.NETWORKS.testnet.defaultGateway) | ||
) | ||
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that these tests are using a private key on a live network, at some point, the wallet address is going to run out of tokens and the tests will fail. Is there some sort fo longer-term plan here, like getting the tests to work with barge? If so, do we have an issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the reason that I did not include the tests in the CI, because everytime the account will be drained, we'll have to top up the funds for those. For the moment it's not tested with CI, only locally. We can create an issue for it. @mihaisc suggested to have a separate job which not runs at every push but he said to leave this problem for now, I'll create an issue for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok cool, fair enough
package.json
Outdated
@@ -30,6 +30,7 @@ | |||
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit", | |||
"test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover", | |||
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'", | |||
"test:sapphire": "npm run mocha -- 'test/scripts/**/*.test.ts'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets move the test file to its proper location /test/integration/
also renaming it to Sapphire.test.ts would be nice
then update the test:saphire to "npm run mocha -- 'test/integration/Sapphire.test.ts'" .. and then just ignore the newloy moved file in the test:integration comand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sure I can do that.
src/contracts/AccessList.ts
Outdated
} | ||
|
||
/** | ||
* Add address to access list | ||
* @param {String} user Minter address | ||
* @param {String} tokenUri tokenURI | ||
* @param {Boolean} estimateGas if True, return gas estimate | ||
* @return {Promise<ReceiptOrEstimate>} transactionId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns the transaction receipt
src/contracts/AccessList.ts
Outdated
* Delete address from access list | ||
* @param {Number} tokenId token ID | ||
* @param {Boolean} estimateGas if True, return gas estimate | ||
* @return {Promise<ReceiptOrEstimate>} transactionId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return {Promise<ReceiptOrEstimate>} transactionId | |
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value |
src/contracts/AccessList.ts
Outdated
user, | ||
tokenUri | ||
) | ||
return <ReceiptOrEstimate<G>>trxReceipt | ||
} | ||
|
||
/** | ||
* Batch Mint ERC721 contract | ||
* @param {String} accessListAddress AccessList contract address | ||
* Batch add addresses to the access list | ||
* @param {String} users Minter addresses | ||
* @param {String} tokenUris tokenURI | ||
* @param {Boolean} estimateGas if True, return gas estimate | ||
* @return {Promise<ReceiptOrEstimate>} transactionId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return {Promise<ReceiptOrEstimate>} transactionId | |
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value |
src/contracts/AccessList.ts
Outdated
* Transfer Ownership of an access list, called by owner of access list | ||
* @param {Number} newOwner new owner of the access list | ||
* @param {Boolean} estimateGas if True, return gas estimate | ||
* @return {Promise<ReceiptOrEstimate>} transactionId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return {Promise<ReceiptOrEstimate>} transactionId | |
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value |
src/contracts/AccessListFactory.ts
Outdated
tokenURI | ||
) | ||
const trxReceipt = await tx.wait() | ||
const events = getEventFromTx(trxReceipt, 'NewAccessList') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the tx fails, need to provide a proper response for the client otherwise the line bellow events.args[0] will fail with uncaught error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the same should be applied in NFTFactory when creating a NFT, try-catch block is missing from there too.
src/config/ConfigHelper.ts
Outdated
{ | ||
...configHelperNetworksBase, | ||
chainId: 23295, | ||
network: 'oasis_saphire_testnet', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is misspelled again, chain name is: oasis_sapphire_testnet
src/contracts/Datatoken4.ts
Outdated
*/ | ||
public async getFileObject( | ||
dtAddress: string, | ||
serviceId: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to refactor all these occurrences of serviceID
(including comments).. It definitely is NOT the service id, but the service index.. so serviceIndex
instead, otherwise we get easily confused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right thing, sure, do that now.
src/contracts/AccessListFactory.ts
Outdated
|
||
/** | ||
* Create new Access List Contract | ||
* @param {AccessListData} listData The data needed to create an NFT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets kill this comment about AccessListData :-)
src/contracts/Datatoken4.ts
Outdated
@@ -30,19 +30,23 @@ export class Datatoken4 extends Datatoken { | |||
abi?: AbiItem[] | |||
) { | |||
super(signer, network, config, abi) | |||
this.abi = this.getDefaultAbi() | |||
// Wrap signer's address for encrypted data tx | |||
this.signer = sapphire.wrap(signer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the template only for confidential EVM sapphire?
Cause we're wrapping the signer with their sdk call sapphire.wrap(...)
..
and we have a few functions doing it again like:
confidentialEVM === true ? sapphire.wrap(this.signer) : this.signer, ...
So, we get a "double" wrap() for confidential EVM and a wrap() for any other EVM using this template
For now, i would just remove the wrap() call on the constructor, and later, once we merge the other PR we can refactor this a bit more (from the config we would know if is confidential evm and if we should wrap the calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the wrapper from constructor to avoid confusions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template 4 is only for confidential EVM, I mean, the scope of its creation is destinated for sapphire and files encryption on sapphire chain.
Fixes # .
Changes proposed in this PR: