From 4dd1f4ff1d4304c9f8d3df60de8858ecb6b42158 Mon Sep 17 00:00:00 2001 From: NtTestAlert <50535142+NtTestAlert@users.noreply.github.com> Date: Thu, 21 Mar 2024 04:06:13 +0100 Subject: [PATCH 1/7] adapt library for cadence1 --- .github/workflows/pull-request.yml | 3 +- .github/workflows/release.yml | 3 +- cadence/contracts/FlowManager.cdc | 80 +++--- cadence/scripts/check-manager.cdc | 2 +- cadence/scripts/get-account-address.cdc | 8 +- cadence/scripts/get-block-offset.cdc | 2 +- cadence/scripts/get-contract-address.cdc | 8 +- cadence/scripts/get-manager-address.cdc | 8 +- cadence/scripts/get-timestamp-offset.cdc | 2 +- cadence/scripts/get_balance.cdc | 22 +- cadence/transactions/create-account.cdc | 22 +- cadence/transactions/deploy-contract.cdc | 6 +- cadence/transactions/init-manager.cdc | 2 +- cadence/transactions/mint_tokens.cdc | 31 ++- cadence/transactions/register-contract.cdc | 6 +- cadence/transactions/scratch.cdc | 4 +- cadence/transactions/set-block-offset.cdc | 2 +- cadence/transactions/set-timestamp-offset.cdc | 2 +- cadence/transactions/update-contract.cdc | 14 +- examples/02-deploy-contract-by-name.test.js | 4 +- examples/03-deploy-contract.test.js | 6 +- examples/05-emulator-management.test.js | 2 +- examples/07-block-offset.test.js | 2 +- examples/08-execute-script.test.js | 2 +- examples/09-send-transaction.test.js | 2 +- .../100-pass-array-of-dictionaries.test.js | 2 +- examples/101-pass-int-dictionary.test.js | 2 +- .../102-pass-string-to-int-dictionary.test.js | 2 +- examples/cadence/contracts/Greeting.cdc | 6 +- examples/cadence/contracts/Hello.cdc | 6 +- examples/cadence/scripts/hello.cdc | 4 +- examples/cadence/scripts/log-args.cdc | 4 +- examples/cadence/scripts/replace-address.cdc | 4 +- examples/cadence/transactions/log-signers.cdc | 4 +- package-lock.json | 178 +------------- package.json | 2 +- src/account.js | 1 + src/crypto.js | 6 +- src/file.js | 15 ++ src/generated/contracts/FlowManager.js | 232 ++++++++++++------ src/generated/scripts/checkManager.js | 6 +- src/generated/scripts/getAccountAddress.js | 24 +- src/generated/scripts/getBalance.js | 30 ++- src/generated/scripts/getBlockOffset.js | 6 +- src/generated/scripts/getContractAddress.js | 24 +- src/generated/scripts/getManagerAddress.js | 19 +- src/generated/scripts/getTimestampOffset.js | 6 +- src/generated/transactions/createAccount.js | 52 ++-- src/generated/transactions/deployContract.js | 40 ++- src/generated/transactions/initManager.js | 18 +- src/generated/transactions/mintTokens.js | 33 ++- .../transactions/registerContract.js | 22 +- src/generated/transactions/scratch.js | 10 +- src/generated/transactions/setBlockOffset.js | 4 +- .../transactions/setTimestampOffset.js | 4 +- src/generated/transactions/updateContract.js | 16 +- src/interaction.js | 12 +- src/manager.js | 2 +- src/storage.js | 89 +++---- src/templates.js | 12 +- test/basic/cadence.test.js | 2 +- test/cadence/contracts/HelloWorld.cdc | 6 +- test/cadence/contracts/utility/Message.cdc | 6 +- test/cadence/scripts/get-message.cdc | 4 +- test/cadence/scripts/log-message.cdc | 4 +- test/cadence/scripts/log-passed-message.cdc | 4 +- .../scripts/read-mocked-block-offset.cdc | 2 +- .../scripts/read-mocked-timestamp-offset.cdc | 2 +- test/cadence/transactions/log-message.cdc | 4 +- .../transactions/log-signer-address.cdc | 4 +- test/integration/account.test.js | 5 +- test/integration/deploy.test.js | 15 +- test/integration/imports.test.js | 7 +- test/integration/interaction.test.js | 29 +-- test/integration/metadata.test.js | 11 +- test/integration/storage.test.js | 19 +- test/integration/transformers.test.js | 2 +- test/integration/usage.test.js | 23 +- test/integration/utilities.test.js | 25 +- test/util/timeout.const.js | 1 + 80 files changed, 628 insertions(+), 689 deletions(-) create mode 100644 test/util/timeout.const.js diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4a6622af..5bd852b2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -29,7 +29,8 @@ jobs: run: ./check-headers.sh - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" +# run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)" - name: Get Flow CLI version id: testbed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fa2ba8b..7342a9b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,8 @@ jobs: - name: Install Flow CLI # We will need Flow CLI in order to run tests, so we need to install it - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" +# run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)" - name: Install Dependencies run: npm ci diff --git a/cadence/contracts/FlowManager.cdc b/cadence/contracts/FlowManager.cdc index dedbed1f..ed20691f 100644 --- a/cadence/contracts/FlowManager.cdc +++ b/cadence/contracts/FlowManager.cdc @@ -1,16 +1,16 @@ -pub contract FlowManager { +access(all) contract FlowManager { /// Account Manager - pub event AccountAdded(address: Address) + access(all) event AccountAdded(address: Address) - pub struct Mapper { - pub let accounts: {String: Address} + access(all) struct Mapper { + access(all) let accounts: {String: Address} - pub fun getAddress(_ name: String): Address? { + access(all) fun getAddress(_ name: String): Address? { return self.accounts[name] } - pub fun setAddress(_ name: String, address: Address){ + access(all) fun setAddress(_ name: String, address: Address){ self.accounts[name] = address emit FlowManager.AccountAdded(address: address) } @@ -20,35 +20,34 @@ pub contract FlowManager { } } - pub fun getAccountAddress(_ name: String): Address?{ + access(all) fun getAccountAddress(_ name: String): Address?{ let accountManager = self.account - .getCapability(self.accountManagerPath) - .borrow<&FlowManager.Mapper>()! + .capabilities.borrow<&FlowManager.Mapper>(self.accountManagerPath)! return accountManager.getAddress(name) } - pub let defaultAccounts: {Address : String} + access(all) let defaultAccounts: {Address : String} - pub fun resolveDefaultAccounts(_ address: Address): Address{ + access(all) fun resolveDefaultAccounts(_ address: Address): Address{ let alias = self.defaultAccounts[address]! return self.getAccountAddress(alias)! } - pub let accountManagerStorage: StoragePath - pub let contractManagerStorage: StoragePath - pub let accountManagerPath: PublicPath - pub let contractManagerPath: PublicPath + access(all) let accountManagerStorage: StoragePath + access(all) let contractManagerStorage: StoragePath + access(all) let accountManagerPath: PublicPath + access(all) let contractManagerPath: PublicPath /// Environment Manager - pub event BlockOffsetChanged(offset: UInt64) - pub event TimestampOffsetChanged(offset: UFix64) + access(all) event BlockOffsetChanged(offset: UInt64) + access(all) event TimestampOffsetChanged(offset: UFix64) - pub struct MockBlock { - pub let id: [UInt8; 32] - pub let height: UInt64 - pub let view: UInt64 - pub let timestamp: UFix64 + access(all) struct MockBlock { + access(all) let id: [UInt8; 32] + access(all) let height: UInt64 + access(all) let view: UInt64 + access(all) let timestamp: UFix64 init(_ id: [UInt8; 32], _ height: UInt64, _ view: UInt64, _ timestamp: UFix64){ self.id = id @@ -58,34 +57,34 @@ pub contract FlowManager { } } - pub fun setBlockOffset(_ offset: UInt64){ + access(all) fun setBlockOffset(_ offset: UInt64){ self.blockOffset = offset emit FlowManager.BlockOffsetChanged(offset: offset) } - pub fun setTimestampOffset(_ offset: UFix64){ + access(all) fun setTimestampOffset(_ offset: UFix64){ self.timestampOffset = offset emit FlowManager.TimestampOffsetChanged(offset: offset) } - pub fun getBlockHeight(): UInt64 { + access(all) fun getBlockHeight(): UInt64 { var block = getCurrentBlock() return block.height + self.blockOffset } - pub fun getBlockTimestamp(): UFix64 { + access(all) fun getBlockTimestamp(): UFix64 { var block = getCurrentBlock() return block.timestamp + self.timestampOffset } - pub fun getBlock(): MockBlock { + access(all) fun getBlock(): MockBlock { var block = getCurrentBlock() let mockBlock = MockBlock(block.id, block.height, block.view, block.timestamp); return mockBlock } - pub var blockOffset: UInt64; - pub var timestampOffset: UFix64; + access(all) var blockOffset: UInt64; + access(all) var timestampOffset: UFix64; // Initialize contract @@ -111,16 +110,23 @@ pub contract FlowManager { self.accountManagerPath = /public/testSuiteAccountManager self.contractManagerPath = /public/testSuiteContractManager - + // Destroy previously stored values - self.account.load(from: self.accountManagerStorage) - self.account.load(from: self.contractManagerStorage) + self.account.storage.load(from: self.accountManagerStorage) + self.account.storage.load(from: self.contractManagerStorage) + + self.account.storage.save(accountManager, to: self.accountManagerStorage) + self.account.storage.save(contractManager, to: self.contractManagerStorage) + - self.account.save(accountManager, to: self.accountManagerStorage) - self.account.save(contractManager, to: self.contractManagerStorage) + self.account.capabilities.publish( + self.account.capabilities.storage.issue<&Mapper>( + self.accountManagerStorage + ), at: self.accountManagerPath) - self.account.link<&Mapper>(self.accountManagerPath, target: self.accountManagerStorage) - self.account.link<&Mapper>(self.contractManagerPath, target: self.contractManagerStorage) + self.account.capabilities.publish( + self.account.capabilities.storage.issue<&Mapper>( + self.contractManagerStorage + ), at: self.contractManagerPath) } } - \ No newline at end of file diff --git a/cadence/scripts/check-manager.cdc b/cadence/scripts/check-manager.cdc index 27c37810..1590243c 100644 --- a/cadence/scripts/check-manager.cdc +++ b/cadence/scripts/check-manager.cdc @@ -1,6 +1,6 @@ import FlowManager from 0x01 -pub fun main(){ +access(all) fun main(){ // the body can be empty, cause script will throw error if FlowManager is not // added to service address } diff --git a/cadence/scripts/get-account-address.cdc b/cadence/scripts/get-account-address.cdc index d5a08474..a7ed42ea 100644 --- a/cadence/scripts/get-account-address.cdc +++ b/cadence/scripts/get-account-address.cdc @@ -1,12 +1,10 @@ import FlowManager from 0x01 -pub fun main(name: String, managerAccount: Address):Address? { +access(all) fun main(name: String, managerAccount: Address):Address? { let manager = getAccount(managerAccount) let linkPath = FlowManager.accountManagerPath - let accountManager = manager - .getCapability(linkPath) - .borrow<&FlowManager.Mapper>()! + let accountManager = manager.capabilities.borrow<&FlowManager.Mapper>(linkPath)! return accountManager.getAddress(name) -} \ No newline at end of file +} diff --git a/cadence/scripts/get-block-offset.cdc b/cadence/scripts/get-block-offset.cdc index e5eca269..b6ffb1c8 100644 --- a/cadence/scripts/get-block-offset.cdc +++ b/cadence/scripts/get-block-offset.cdc @@ -1,5 +1,5 @@ import FlowManager from 0x01 -pub fun main():UInt64 { +access(all) fun main():UInt64 { return FlowManager.blockOffset } diff --git a/cadence/scripts/get-contract-address.cdc b/cadence/scripts/get-contract-address.cdc index 5ba3b473..359711b4 100644 --- a/cadence/scripts/get-contract-address.cdc +++ b/cadence/scripts/get-contract-address.cdc @@ -1,12 +1,10 @@ import FlowManager from 0x01 -pub fun main(name: String, managerAccount: Address):Address? { +access(all) fun main(name: String, managerAccount: Address):Address? { let manager = getAccount(managerAccount) let linkPath = FlowManager.contractManagerPath - let contractManager = manager - .getCapability(linkPath) - .borrow<&FlowManager.Mapper>()! + let contractManager = manager.capabilities.borrow<&FlowManager.Mapper>(linkPath)! return contractManager.getAddress(name) -} \ No newline at end of file +} diff --git a/cadence/scripts/get-manager-address.cdc b/cadence/scripts/get-manager-address.cdc index 8910d75f..d1bbe913 100644 --- a/cadence/scripts/get-manager-address.cdc +++ b/cadence/scripts/get-manager-address.cdc @@ -1,9 +1,7 @@ -pub fun main(serviceAddress: Address): Address? { +access(all) fun main(serviceAddress: Address): Address? { let account = getAccount(serviceAddress) - let ref = account - .getCapability(/public/flowManagerAddress) - .borrow<&[Address]>()! + + let ref = account.capabilities.borrow<&[Address]>(/public/flowManagerAddress)! return ref[0] } - \ No newline at end of file diff --git a/cadence/scripts/get-timestamp-offset.cdc b/cadence/scripts/get-timestamp-offset.cdc index dc161ef8..4dcb6a8d 100644 --- a/cadence/scripts/get-timestamp-offset.cdc +++ b/cadence/scripts/get-timestamp-offset.cdc @@ -1,5 +1,5 @@ import FlowManager from 0x01 -pub fun main():UFix64 { +access(all) fun main():UFix64 { return FlowManager.timestampOffset } diff --git a/cadence/scripts/get_balance.cdc b/cadence/scripts/get_balance.cdc index 427f21bc..c0b4c5a1 100644 --- a/cadence/scripts/get_balance.cdc +++ b/cadence/scripts/get_balance.cdc @@ -1,12 +1,16 @@ -// This script reads the balance field of an account's FlowToken Balance +// This script reads the balance field +// of an account's ExampleToken Balance -import FungibleToken from 0xFUNGIBLETOKENADDRESS -import ExampleToken from 0xTOKENADDRESS +import FungibleToken from 0x1 +import ExampleToken from 0x1 +import FungibleTokenMetadataViews from 0x1 -pub fun main(account: Address): UFix64 { - let acct = getAccount(account) - let vaultRef = acct.getCapability(/public/exampleTokenBalance)!.borrow<&ExampleToken.Vault{FungibleToken.Balance}>() - ?? panic("Could not borrow Balance reference to the Vault") +access(all) fun main(address: Address): UFix64 { + let vaultData = ExampleToken.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not get vault data view for the contract") - return vaultRef.balance -} \ No newline at end of file + return getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>( + vaultData.metadataPath + )?.balance + ?? panic("Could not borrow Balance reference to the Vault") +} diff --git a/cadence/transactions/create-account.cdc b/cadence/transactions/create-account.cdc index e01186a8..261af2b5 100644 --- a/cadence/transactions/create-account.cdc +++ b/cadence/transactions/create-account.cdc @@ -1,18 +1,26 @@ import FlowManager from 0x01 transaction (_ name: String?, pubKey: [String], manager: Address) { - prepare( admin: AuthAccount) { - let newAccount = AuthAccount(payer:admin) + prepare( admin: auth(BorrowValue) &Account) { + let newAccount = Account(payer:admin) for key in pubKey { - newAccount.addPublicKey(key.decodeHex()) + let keyData = RLP.decodeList(key.decodeHex()) + let rawSign = RLP.decodeString(keyData[1])[0] + let rawHash = RLP.decodeString(keyData[2])[0] + newAccount.keys.add( + publicKey: PublicKey( + publicKey: RLP.decodeString(keyData[0]), + signatureAlgorithm: SignatureAlgorithm(rawValue: rawSign)! + ), + hashAlgorithm: HashAlgorithm(rawValue: rawHash)!, + weight: UFix64(Int32.fromBigEndianBytes(RLP.decodeString(keyData[3]))!)! + ) } if name != nil { let linkPath = FlowManager.accountManagerPath - let accountManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! - + let accountManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! + // Create a record in account database let address = newAccount.address accountManager.setAddress(name!, address: address) diff --git a/cadence/transactions/deploy-contract.cdc b/cadence/transactions/deploy-contract.cdc index 380af2ff..33c282a2 100644 --- a/cadence/transactions/deploy-contract.cdc +++ b/cadence/transactions/deploy-contract.cdc @@ -1,7 +1,7 @@ import FlowManager from 0x01 transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { - prepare(acct: AuthAccount){ + prepare(acct: auth(AddContract) &Account) { let decoded = code.decodeHex() acct.contracts.add( name: name, @@ -10,9 +10,7 @@ transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { ) let linkPath = FlowManager.contractManagerPath - let contractManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! let address = acct.address contractManager.setAddress(name, address: address) diff --git a/cadence/transactions/init-manager.cdc b/cadence/transactions/init-manager.cdc index d8870e95..3ccee566 100644 --- a/cadence/transactions/init-manager.cdc +++ b/cadence/transactions/init-manager.cdc @@ -1,5 +1,5 @@ transaction ( code: String ) { - prepare( admin: AuthAccount) { + prepare( admin: &Account) { admin.contracts.add( name: "FlowManager", code: code.decodeHex(), diff --git a/cadence/transactions/mint_tokens.cdc b/cadence/transactions/mint_tokens.cdc index 9b694ba4..79a324a6 100644 --- a/cadence/transactions/mint_tokens.cdc +++ b/cadence/transactions/mint_tokens.cdc @@ -1,19 +1,24 @@ -import FungibleToken from 0xFUNGIBLETOKENADDRESS -import ExampleToken from 0xTOKENADDRESS +import FungibleToken from 0x1 +import ExampleToken from 0x1 +import FungibleTokenMetadataViews from 0x1 transaction(recipient: Address, amount: UFix64) { - let tokenAdmin: &ExampleToken.Administrator + let tokenAdmin: &FlowToken.Administrator let tokenReceiver: &{FungibleToken.Receiver} + let supplyBefore: UFix64 - prepare(signer: AuthAccount) { - self.tokenAdmin = signer - .borrow<&ExampleToken.Administrator>(from: /storage/exampleTokenAdmin) - ?? panic("Signer is not the token admin") + prepare(signer: auth(BorrowValue) &Account) { + self.supplyBefore = ExampleToken.totalSupply - self.tokenReceiver = getAccount(recipient) - .getCapability(/public/exampleTokenReceiver)! - .borrow<&{FungibleToken.Receiver}>() - ?? panic("Unable to borrow receiver reference") + // Borrow a reference to the admin object + self.tokenAdmin = signer.storage.borrow<&ExampleToken.Administrator>(from: ExampleToken.AdminStoragePath) + ?? panic("Signer is not the token admin") + + let vaultData = ExampleToken.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not get vault data view for the contract") + + self.tokenReceiver = getAccount(recipient).capabilities.borrow<&{FungibleToken.Receiver}>(vaultData.receiverPath) + ?? panic("Could not borrow receiver reference to the Vault") } execute { @@ -24,4 +29,8 @@ transaction(recipient: Address, amount: UFix64) { destroy minter } + + post { + ExampleToken.totalSupply == self.supplyBefore + amount: "The total supply must be increased by the amount" + } } diff --git a/cadence/transactions/register-contract.cdc b/cadence/transactions/register-contract.cdc index 6068b647..74fa7cc8 100644 --- a/cadence/transactions/register-contract.cdc +++ b/cadence/transactions/register-contract.cdc @@ -1,11 +1,9 @@ import FlowManager from 0x01 transaction(name: String, address: Address) { - prepare(signer: AuthAccount){ + prepare(signer: auth(BorrowValue) &Account){ let linkPath = FlowManager.contractManagerPath - let contractManager = signer - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! contractManager.setAddress(name, address: address) } } diff --git a/cadence/transactions/scratch.cdc b/cadence/transactions/scratch.cdc index 79883c3a..345ff9a5 100644 --- a/cadence/transactions/scratch.cdc +++ b/cadence/transactions/scratch.cdc @@ -1,5 +1,5 @@ transaction{ - prepare(acct: AuthAccount){ + prepare(acct: &Account){ log(acct.address) } -} \ No newline at end of file +} diff --git a/cadence/transactions/set-block-offset.cdc b/cadence/transactions/set-block-offset.cdc index 84fd2d64..3d40498d 100644 --- a/cadence/transactions/set-block-offset.cdc +++ b/cadence/transactions/set-block-offset.cdc @@ -1,7 +1,7 @@ import FlowManager from 0x01 transaction(offset: UInt64){ - prepare(signer:AuthAccount){ + prepare(signer: &Account){ FlowManager.setBlockOffset(offset) } } diff --git a/cadence/transactions/set-timestamp-offset.cdc b/cadence/transactions/set-timestamp-offset.cdc index 04bb77f2..27714056 100644 --- a/cadence/transactions/set-timestamp-offset.cdc +++ b/cadence/transactions/set-timestamp-offset.cdc @@ -1,7 +1,7 @@ import FlowManager from 0x01 transaction(offset: UFix64){ - prepare(signer:AuthAccount){ + prepare(signer: &Account){ FlowManager.setTimestampOffset(offset) } } diff --git a/cadence/transactions/update-contract.cdc b/cadence/transactions/update-contract.cdc index 879a08ef..183c4bd5 100644 --- a/cadence/transactions/update-contract.cdc +++ b/cadence/transactions/update-contract.cdc @@ -1,19 +1,21 @@ import FlowManager from 0x01 transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { - prepare(acct: AuthAccount){ + prepare(acct: auth(AddContract, UpdateContract) &Account){ let decoded = code.decodeHex() if acct.contracts.get(name: name) == nil { - acct.contracts.add(name: name, code: decoded) + acct.contracts.add( + name: name, + code: decoded, + ##ARGS-LIST## + ) } else { - acct.contracts.update__experimental(name: name, code: decoded) + acct.contracts.update(name: name, code: decoded) } let linkPath = FlowManager.contractManagerPath - let contractManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! let address = acct.address contractManager.setAddress(name, address: address) diff --git a/examples/02-deploy-contract-by-name.test.js b/examples/02-deploy-contract-by-name.test.js index 272ce505..2c8a38eb 100644 --- a/examples/02-deploy-contract-by-name.test.js +++ b/examples/02-deploy-contract-by-name.test.js @@ -32,7 +32,7 @@ test("deploy contract by name", async () => { code: ` import Greeting from 0x1 - pub fun main(): String{ + access(all) fun main(): String{ return Greeting.message } `, @@ -47,7 +47,7 @@ test("deploy contract by name", async () => { code: ` import Hello from 0x01 - pub fun main():String{ + access(all) fun main():String{ return Hello.message } `, diff --git a/examples/03-deploy-contract.test.js b/examples/03-deploy-contract.test.js index b23ede4b..023babb0 100644 --- a/examples/03-deploy-contract.test.js +++ b/examples/03-deploy-contract.test.js @@ -22,8 +22,8 @@ test("deploy contract", async () => { const name = "Wallet" const code = ` - pub contract Wallet{ - pub let balance: UInt + access(all) contract Wallet{ + access(all) let balance: UInt init(balance: UInt){ self.balance = balance } @@ -37,7 +37,7 @@ test("deploy contract", async () => { executeScript({ code: ` import Wallet from 0x01 - pub fun main(): UInt{ + access(all) fun main(): UInt{ return Wallet.balance } `, diff --git a/examples/05-emulator-management.test.js b/examples/05-emulator-management.test.js index c2f7609a..ea9e104a 100644 --- a/examples/05-emulator-management.test.js +++ b/examples/05-emulator-management.test.js @@ -24,7 +24,7 @@ test("emulator management", async () => { const logMessage = async message => { return executeScript({ code: ` - pub fun main(){ + access(all) fun main(){ log("------------> ${message}") } `, diff --git a/examples/07-block-offset.test.js b/examples/07-block-offset.test.js index dbf3f984..7e034972 100644 --- a/examples/07-block-offset.test.js +++ b/examples/07-block-offset.test.js @@ -22,7 +22,7 @@ test("block offset", async () => { // "getCurrentBlock().height" in your Cadence code will be replaced by Manager to a mocked value const code = ` - pub fun main(): UInt64 { + access(all) fun main(): UInt64 { return getCurrentBlock().height } ` diff --git a/examples/08-execute-script.test.js b/examples/08-execute-script.test.js index 2430f1b2..438fb6c6 100644 --- a/examples/08-execute-script.test.js +++ b/examples/08-execute-script.test.js @@ -12,7 +12,7 @@ test("execute script", async () => { // We have created a file called "log-args.cdc" under "./cadence/scripts" folder. // It's available for use since we configured framework to use "./cadence" folder as root const code = ` - pub fun main(a: Int, b: Bool, c: String, d: UFix64, e: [Int], f: {String: String}, res: Int): Int{ + access(all) fun main(a: Int, b: Bool, c: String, d: UFix64, e: [Int], f: {String: String}, res: Int): Int{ log(a) log(b) log(c) diff --git a/examples/09-send-transaction.test.js b/examples/09-send-transaction.test.js index 47e8629a..bba50b54 100644 --- a/examples/09-send-transaction.test.js +++ b/examples/09-send-transaction.test.js @@ -23,7 +23,7 @@ test("send transaction", async () => { const name = "log-signers" const code = ` transaction(message: String){ - prepare(first: AuthAccount, second: AuthAccount){ + prepare(first: &Account, second: &Account){ log(message) log(first.address) log(second.address) diff --git a/examples/100-pass-array-of-dictionaries.test.js b/examples/100-pass-array-of-dictionaries.test.js index 0692d127..38663eec 100644 --- a/examples/100-pass-array-of-dictionaries.test.js +++ b/examples/100-pass-array-of-dictionaries.test.js @@ -10,7 +10,7 @@ beforeEach(async () => { test("pass array of dictionaries", async () => { const code = ` - pub fun main(meta: [{String:String}], key: String): String?{ + access(all) fun main(meta: [{String:String}], key: String): String?{ return meta[0]![key] } ` diff --git a/examples/101-pass-int-dictionary.test.js b/examples/101-pass-int-dictionary.test.js index fac5e763..eac51e2f 100644 --- a/examples/101-pass-int-dictionary.test.js +++ b/examples/101-pass-int-dictionary.test.js @@ -10,7 +10,7 @@ beforeEach(async () => { test("pass int dictionary", async () => { const code = ` - pub fun main(data: {UInt32: UInt32}, key: UInt32): UInt32?{ + access(all) fun main(data: {UInt32: UInt32}, key: UInt32): UInt32?{ return data[key] } ` diff --git a/examples/102-pass-string-to-int-dictionary.test.js b/examples/102-pass-string-to-int-dictionary.test.js index fb4d0bdc..a6649c6f 100644 --- a/examples/102-pass-string-to-int-dictionary.test.js +++ b/examples/102-pass-string-to-int-dictionary.test.js @@ -10,7 +10,7 @@ beforeEach(async () => { test("pass string to int dictionary", async () => { const code = ` - pub fun main(data: {String: UInt32}, key: String): UInt32?{ + access(all) fun main(data: {String: UInt32}, key: String): UInt32?{ return data[key] } ` diff --git a/examples/cadence/contracts/Greeting.cdc b/examples/cadence/contracts/Greeting.cdc index 48d5217d..fef49fe1 100644 --- a/examples/cadence/contracts/Greeting.cdc +++ b/examples/cadence/contracts/Greeting.cdc @@ -1,9 +1,9 @@ import FungibleToken from 0x1 -pub contract Greeting{ - pub let message: String +access(all) contract Greeting{ + access(all) let message: String init(message: String){ self.message = message } -} \ No newline at end of file +} diff --git a/examples/cadence/contracts/Hello.cdc b/examples/cadence/contracts/Hello.cdc index 1e160138..098d03c1 100644 --- a/examples/cadence/contracts/Hello.cdc +++ b/examples/cadence/contracts/Hello.cdc @@ -1,7 +1,7 @@ -pub contract Hello{ - pub let message: String +access(all) contract Hello{ + access(all) let message: String init(){ self.message = "Hi!" } -} \ No newline at end of file +} diff --git a/examples/cadence/scripts/hello.cdc b/examples/cadence/scripts/hello.cdc index 86affdca..328c0206 100644 --- a/examples/cadence/scripts/hello.cdc +++ b/examples/cadence/scripts/hello.cdc @@ -1,3 +1,3 @@ -pub fun main(): String{ +access(all) fun main(): String{ return "Hello from Cadence" -} \ No newline at end of file +} diff --git a/examples/cadence/scripts/log-args.cdc b/examples/cadence/scripts/log-args.cdc index 3132f8af..e14240c6 100644 --- a/examples/cadence/scripts/log-args.cdc +++ b/examples/cadence/scripts/log-args.cdc @@ -1,4 +1,4 @@ -pub fun main(a: Int, b: Bool, c: String, d: UFix64, e: [Int], f: {String: String}, res: Int): Int{ +access(all) fun main(a: Int, b: Bool, c: String, d: UFix64, e: [Int], f: {String: String}, res: Int): Int{ log(a) log(b) log(c) @@ -7,4 +7,4 @@ pub fun main(a: Int, b: Bool, c: String, d: UFix64, e: [Int], f: {String: String log(f) return res -} \ No newline at end of file +} diff --git a/examples/cadence/scripts/replace-address.cdc b/examples/cadence/scripts/replace-address.cdc index ffc142cc..b447fdd4 100644 --- a/examples/cadence/scripts/replace-address.cdc +++ b/examples/cadence/scripts/replace-address.cdc @@ -1,6 +1,6 @@ import FungibleToken from 0x01 import Profile from 0xProfile -pub fun main(): Int{ +access(all) fun main(): Int{ return 42 -} \ No newline at end of file +} diff --git a/examples/cadence/transactions/log-signers.cdc b/examples/cadence/transactions/log-signers.cdc index 3f744ca6..a8438da7 100644 --- a/examples/cadence/transactions/log-signers.cdc +++ b/examples/cadence/transactions/log-signers.cdc @@ -1,7 +1,7 @@ transaction(message: String){ - prepare(first: AuthAccount, second: AuthAccount){ + prepare(first: &Account, second: &Account){ log(message) log(first.address) log(second.address) } -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 630dd12b..286323c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@onflow/flow-js-testing", - "version": "0.3.0-alpha.17", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@onflow/flow-js-testing", - "version": "0.3.0-alpha.17", + "version": "0.4.0", "license": "Apache-2.0", "dependencies": { "@onflow/fcl": "^1.3.2", @@ -30,7 +30,6 @@ "@babel/preset-env": "^7.14.5", "@changesets/changelog-github": "^0.4.5", "@changesets/cli": "^2.23.0", - "@onflow/flow-cadut-generator": "0.0.1", "babel-jest": "^27.0.2", "eslint": "^7.24.0", "eslint-config-prettier": "^8.5.0", @@ -2821,21 +2820,6 @@ "sha3": "^2.1.4" } }, - "node_modules/@onflow/flow-cadut-generator": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@onflow/flow-cadut-generator/-/flow-cadut-generator-0.0.1.tgz", - "integrity": "sha512-3yqaQHazZLqJoXwt54E9SE4Rdmnm17jDmLT3S40ec2L8v3R82ZullPdzApESEX1Yh2+oYd98xjqyLZXo96oFPg==", - "dev": true, - "dependencies": { - "@babel/runtime": "^7.18.6", - "@onflow/flow-cadut": "^0.2.0-alpha.8", - "handlebars": "^4.7.7", - "handlebars-loader": "^1.7.1" - }, - "bin": { - "flow-generate": "dist/generate.js" - } - }, "node_modules/@onflow/flow-cadut/node_modules/@onflow/config": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/@onflow/config/-/config-0.0.2.tgz", @@ -3563,12 +3547,6 @@ "node": ">=8" } }, - "node_modules/async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", - "dev": true - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -5841,12 +5819,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "node_modules/fastparse": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", - "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==", - "dev": true - }, "node_modules/fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -6266,51 +6238,6 @@ "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", "dev": true }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/handlebars-loader": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/handlebars-loader/-/handlebars-loader-1.7.3.tgz", - "integrity": "sha512-dDb+8D51vE3OTSE2wuGPWRAegtsEuw8Mk8hCjtRu/pNcBfN5q+M8ZG3kVJxBuOeBrVElpFStipGmaxSBTRR1mQ==", - "dev": true, - "dependencies": { - "async": "^3.2.2", - "fastparse": "^1.0.0", - "loader-utils": "1.4.x", - "object-assign": "^4.1.0" - }, - "peerDependencies": { - "handlebars": ">= 1.3.0 < 5" - } - }, - "node_modules/handlebars/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/hard-rejection": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", @@ -10256,12 +10183,6 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, "node_modules/nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -13867,19 +13788,6 @@ "node": ">=4.2.0" } }, - "node_modules/uglify-js": { - "version": "3.16.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.16.3.tgz", - "integrity": "sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -14258,12 +14166,6 @@ "node": ">=0.10.0" } }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -16723,18 +16625,6 @@ } } }, - "@onflow/flow-cadut-generator": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@onflow/flow-cadut-generator/-/flow-cadut-generator-0.0.1.tgz", - "integrity": "sha512-3yqaQHazZLqJoXwt54E9SE4Rdmnm17jDmLT3S40ec2L8v3R82ZullPdzApESEX1Yh2+oYd98xjqyLZXo96oFPg==", - "dev": true, - "requires": { - "@babel/runtime": "^7.18.6", - "@onflow/flow-cadut": "^0.2.0-alpha.8", - "handlebars": "^4.7.7", - "handlebars-loader": "^1.7.1" - } - }, "@onflow/interaction": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/@onflow/interaction/-/interaction-0.0.11.tgz", @@ -17352,12 +17242,6 @@ "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, - "async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -19190,12 +19074,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fastparse": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", - "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==", - "dev": true - }, "fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -19532,39 +19410,6 @@ } } }, - "handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "requires": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4", - "wordwrap": "^1.0.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "handlebars-loader": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/handlebars-loader/-/handlebars-loader-1.7.3.tgz", - "integrity": "sha512-dDb+8D51vE3OTSE2wuGPWRAegtsEuw8Mk8hCjtRu/pNcBfN5q+M8ZG3kVJxBuOeBrVElpFStipGmaxSBTRR1mQ==", - "dev": true, - "requires": { - "async": "^3.2.2", - "fastparse": "^1.0.0", - "loader-utils": "1.4.x", - "object-assign": "^4.1.0" - } - }, "hard-rejection": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", @@ -22702,12 +22547,6 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -25569,13 +25408,6 @@ "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "dev": true }, - "uglify-js": { - "version": "3.16.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.16.3.tgz", - "integrity": "sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==", - "dev": true, - "optional": true - }, "unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -25877,12 +25709,6 @@ "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", "dev": true }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true - }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index ac1283cc..c904fbd9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "scripts": { "build": "microbundle --no-compress", - "generate-code": "node_modules/.bin/flow-generate -i ./cadence -o ./src/generated", + "generate-code": "echo manually edited, do not run // node_modules/.bin/flow-generate -i ./cadence -o ./src/generated", "lint": "eslint -c .eslintrc.js src", "check-headers": "sh ./check-headers.sh", "prettify": "prettier --write ./src", diff --git a/src/account.js b/src/account.js index 5ba94f82..5b68a07d 100644 --- a/src/account.js +++ b/src/account.js @@ -35,6 +35,7 @@ export async function createAccount({name, keys}) { // If public key is encoded already, don't change // If provided as KeyObject (private key) generate public key + // TODO since old key API is deprecated, might want to pass the key in a different way (struct?) keys = await Promise.all( keys.map(key => (isObject(key) ? pubFlowKey(key) : key)) ) diff --git a/src/crypto.js b/src/crypto.js index 00ba8ba9..b9fdd26b 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -58,8 +58,8 @@ import {sha256 as sha2_256} from "js-sha256" * @enum {number} */ export const SignatureAlgorithm = { - ECDSA_P256: 2, - ECDSA_secp256k1: 3, + ECDSA_P256: 1, + ECDSA_secp256k1: 2, } /** @@ -215,7 +215,7 @@ export const pubFlowKey = async (keyObject = {}) => { weight = 1000, // give key full weight } = keyObject - // Converty hex string private key to buffer if not buffer already + // Convert hex string private key to buffer if not buffer already if (!Buffer.isBuffer(privateKey)) privateKey = Buffer.from(privateKey, "hex") const hashAlgoName = resolveHashAlgoKey(hashAlgorithm) diff --git a/src/file.js b/src/file.js index ac0a4e0c..823e21dc 100644 --- a/src/file.js +++ b/src/file.js @@ -34,12 +34,27 @@ export const readFile = path => { export const defaultsByName = { FlowToken: "0x0ae53cb6e3f42a79", FungibleToken: "0xee82856bf20e2aa6", + FungibleTokenMetadataViews: "0xee82856bf20e2aa6", + FungibleTokenSwitchboard: "0xee82856bf20e2aa6", FlowFees: "0xe5a8b7f23e8b548f", FlowStorageFees: "0xf8d6e0586b0a20c7", + FlowIDTableStaking: "0xf8d6e0586b0a20c7", + FlowEpoch: "0xf8d6e0586b0a20c7", + FlowClusterQC: "0xf8d6e0586b0a20c7", + FlowDKG: "0xf8d6e0586b0a20c7", + FlowStakingCollection: "0xf8d6e0586b0a20c7", + + FlowServiceAccount: "0xf8d6e0586b0a20c7", + RandomBeaconHistory: "0xf8d6e0586b0a20c7", + NodeVersionBeacon: "0xf8d6e0586b0a20c7", + + EVM: "0xf8d6e0586b0a20c7", + FUSD: "0xf8d6e0586b0a20c7", NonFungibleToken: "0xf8d6e0586b0a20c7", MetadataViews: "0xf8d6e0586b0a20c7", + ViewResolver: "0xf8d6e0586b0a20c7", NFTStorefront: "0xf8d6e0586b0a20c7", NFTStorefrontV2: "0xf8d6e0586b0a20c7", } diff --git a/src/generated/contracts/FlowManager.js b/src/generated/contracts/FlowManager.js index d7bb73e7..919d045d 100644 --- a/src/generated/contracts/FlowManager.js +++ b/src/generated/contracts/FlowManager.js @@ -1,26 +1,27 @@ -/** pragma type contract **/ - -import { - getEnvironment, - replaceImportAddresses, - reportMissingImports, - deployContract, -} from '@onflow/flow-cadut' - -export const CODE = ` -pub contract FlowManager { +/** pragma type contract **/ + +import { + getEnvironment, + replaceImportAddresses, + reportMissingImports, + // deployContract, // TODO broken, using our own version + sendTransaction, +} from '@onflow/flow-cadut' + +export const CODE = ` +access(all) contract FlowManager { /// Account Manager - pub event AccountAdded(address: Address) + access(all) event AccountAdded(address: Address) - pub struct Mapper { - pub let accounts: {String: Address} + access(all) struct Mapper { + access(all) let accounts: {String: Address} - pub fun getAddress(_ name: String): Address? { + access(all) fun getAddress(_ name: String): Address? { return self.accounts[name] } - pub fun setAddress(_ name: String, address: Address){ + access(all) fun setAddress(_ name: String, address: Address){ self.accounts[name] = address emit FlowManager.AccountAdded(address: address) } @@ -30,35 +31,34 @@ pub contract FlowManager { } } - pub fun getAccountAddress(_ name: String): Address?{ + access(all) fun getAccountAddress(_ name: String): Address?{ let accountManager = self.account - .getCapability(self.accountManagerPath) - .borrow<&FlowManager.Mapper>()! + .capabilities.borrow<&FlowManager.Mapper>(self.accountManagerPath)! return accountManager.getAddress(name) } - pub let defaultAccounts: {Address : String} + access(all) let defaultAccounts: {Address : String} - pub fun resolveDefaultAccounts(_ address: Address): Address{ + access(all) fun resolveDefaultAccounts(_ address: Address): Address{ let alias = self.defaultAccounts[address]! return self.getAccountAddress(alias)! } - pub let accountManagerStorage: StoragePath - pub let contractManagerStorage: StoragePath - pub let accountManagerPath: PublicPath - pub let contractManagerPath: PublicPath + access(all) let accountManagerStorage: StoragePath + access(all) let contractManagerStorage: StoragePath + access(all) let accountManagerPath: PublicPath + access(all) let contractManagerPath: PublicPath /// Environment Manager - pub event BlockOffsetChanged(offset: UInt64) - pub event TimestampOffsetChanged(offset: UFix64) + access(all) event BlockOffsetChanged(offset: UInt64) + access(all) event TimestampOffsetChanged(offset: UFix64) - pub struct MockBlock { - pub let id: [UInt8; 32] - pub let height: UInt64 - pub let view: UInt64 - pub let timestamp: UFix64 + access(all) struct MockBlock { + access(all) let id: [UInt8; 32] + access(all) let height: UInt64 + access(all) let view: UInt64 + access(all) let timestamp: UFix64 init(_ id: [UInt8; 32], _ height: UInt64, _ view: UInt64, _ timestamp: UFix64){ self.id = id @@ -68,34 +68,34 @@ pub contract FlowManager { } } - pub fun setBlockOffset(_ offset: UInt64){ + access(all) fun setBlockOffset(_ offset: UInt64){ self.blockOffset = offset emit FlowManager.BlockOffsetChanged(offset: offset) } - pub fun setTimestampOffset(_ offset: UFix64){ + access(all) fun setTimestampOffset(_ offset: UFix64){ self.timestampOffset = offset emit FlowManager.TimestampOffsetChanged(offset: offset) } - pub fun getBlockHeight(): UInt64 { + access(all) fun getBlockHeight(): UInt64 { var block = getCurrentBlock() return block.height + self.blockOffset } - pub fun getBlockTimestamp(): UFix64 { + access(all) fun getBlockTimestamp(): UFix64 { var block = getCurrentBlock() return block.timestamp + self.timestampOffset } - pub fun getBlock(): MockBlock { + access(all) fun getBlock(): MockBlock { var block = getCurrentBlock() let mockBlock = MockBlock(block.id, block.height, block.view, block.timestamp); return mockBlock } - pub var blockOffset: UInt64; - pub var timestampOffset: UFix64; + access(all) var blockOffset: UInt64; + access(all) var timestampOffset: UFix64; // Initialize contract @@ -121,49 +121,121 @@ pub contract FlowManager { self.accountManagerPath = /public/testSuiteAccountManager self.contractManagerPath = /public/testSuiteContractManager - + // Destroy previously stored values - self.account.load(from: self.accountManagerStorage) - self.account.load(from: self.contractManagerStorage) + self.account.storage.load(from: self.accountManagerStorage) + self.account.storage.load(from: self.contractManagerStorage) + + self.account.storage.save(accountManager, to: self.accountManagerStorage) + self.account.storage.save(contractManager, to: self.contractManagerStorage) + - self.account.save(accountManager, to: self.accountManagerStorage) - self.account.save(contractManager, to: self.contractManagerStorage) + self.account.capabilities.publish( + self.account.capabilities.storage.issue<&Mapper>( + self.accountManagerStorage + ), at: self.accountManagerPath) - self.account.link<&Mapper>(self.accountManagerPath, target: self.accountManagerStorage) - self.account.link<&Mapper>(self.contractManagerPath, target: self.contractManagerStorage) + self.account.capabilities.publish( + self.account.capabilities.storage.issue<&Mapper>( + self.contractManagerStorage + ), at: self.contractManagerPath) } } - -`; - -/** -* Method to generate cadence code for FlowManager contract -* @param {Object.} addressMap - contract name as a key and address where it's deployed as value -*/ -export const FlowManagerTemplate = async (addressMap = {}) => { - const envMap = await getEnvironment(); - const fullMap = { - ...envMap, - ...addressMap, - }; - - // If there are any missing imports in fullMap it will be reported via console - reportMissingImports(CODE, fullMap, `FlowManager =>`) - - return replaceImportAddresses(CODE, fullMap); -}; - - -/** -* Deploys FlowManager transaction to the network -* @param {Object.} addressMap - contract name as a key and address where it's deployed as value -* @param Array<*> args - list of arguments -* param Array - list of signers -*/ -export const deployFlowManager = async (props) => { - const { addressMap = {} } = props; - const code = await FlowManagerTemplate(addressMap); - const name = "FlowManager" - - return deployContract({ code, name, processed: true, ...props }) -} \ No newline at end of file + +`; + +/** +* Method to generate cadence code for FlowManager contract +* @param {Object.} addressMap - contract name as a key and address where it's deployed as value +*/ +export const FlowManagerTemplate = async (addressMap = {}) => { + const envMap = await getEnvironment(); + const fullMap = { + ...envMap, + ...addressMap, + }; + + // If there are any missing imports in fullMap it will be reported via console + reportMissingImports(CODE, fullMap, `FlowManager =>`) + + return replaceImportAddresses(CODE, fullMap); +}; + +// TODO copied from cadut and patched for Cadence 1.0 +const deployContract = async props => { + const { + name, + to, + payer, + proposer, + code: contractCode, + update = false, + processed = false, + addressMap = {}, + } = props + + // Update imprort statement with addresses from addressMap + const ixContractCode = processed + ? contractCode + : replaceImportAddresses(contractCode, addressMap) + + // TODO: Implement arguments for "init" method + const template = update ? ` + transaction(name: String, code: String) { + prepare(acct: auth(AddContract) &Account) { + let decoded = code.decodeHex() + + acct.contracts.add( + name: name, + code: decoded, + ) + } + } + ` : ` + transaction(name: String, code: String){ + prepare(acct: auth(AddContract, UpdateContract) &Account) { + let decoded = code.decodeHex() + + if acct.contracts.get(name: name) == nil { + acct.contracts.add(name: name, code: decoded) + } else { + acct.contracts.update(name: name, code: decoded) + } + } + } +` + + const hexedCode = Buffer.from(ixContractCode, "utf8").toString("hex") + const args = [name, hexedCode] + // Set roles + let ixProposer = to + let ixPayer = to + let ixSigners = [to] + + if (payer) { + ixPayer = payer + ixProposer = proposer || payer + } + + return await sendTransaction({ + payer: ixPayer, + proposer: ixProposer, + signers: ixSigners, + code: template, + args, + }); +} + +/** +* Deploys FlowManager transaction to the network +* @param {Object.} addressMap - contract name as a key and address where it's deployed as value +* @param Array<*> args - list of arguments +* param Array - list of signers +*/ +export const deployFlowManager = async (props) => { + const { addressMap = {} } = props; + const code = await FlowManagerTemplate(addressMap); + const name = "FlowManager" + + return deployContract({ code, name, processed: true, ...props }) +} diff --git a/src/generated/scripts/checkManager.js b/src/generated/scripts/checkManager.js index de5def10..c1fb8602 100644 --- a/src/generated/scripts/checkManager.js +++ b/src/generated/scripts/checkManager.js @@ -5,13 +5,13 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` import FlowManager from 0x01 -pub fun main(){ +access(all) fun main(){ // the body can be empty, cause script will throw error if FlowManager is not // added to service address } @@ -42,4 +42,4 @@ export const checkManager = async (props = {}) => { reportMissing("arguments", args.length, 0, `checkManager =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getAccountAddress.js b/src/generated/scripts/getAccountAddress.js index 38f4b5d9..bcac7da7 100644 --- a/src/generated/scripts/getAccountAddress.js +++ b/src/generated/scripts/getAccountAddress.js @@ -5,21 +5,19 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` -import FlowManager from 0x01 - -pub fun main(name: String, managerAccount: Address):Address? { - let manager = getAccount(managerAccount) - let linkPath = FlowManager.accountManagerPath - let accountManager = manager - .getCapability(linkPath) - .borrow<&FlowManager.Mapper>()! - - return accountManager.getAddress(name) - +import FlowManager from 0x01 + +access(all) fun main(name: String, managerAccount: Address):Address? { + let manager = getAccount(managerAccount) + let linkPath = FlowManager.accountManagerPath + let accountManager = manager.capabilities.borrow<&FlowManager.Mapper>(linkPath)! + + return accountManager.getAddress(name) + } `; @@ -47,4 +45,4 @@ export const getAccountAddress = async (props = {}) => { reportMissing("arguments", args.length, 2, `getAccountAddress =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getBalance.js b/src/generated/scripts/getBalance.js index 535a23b4..2b1326eb 100644 --- a/src/generated/scripts/getBalance.js +++ b/src/generated/scripts/getBalance.js @@ -5,21 +5,25 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` -// This script reads the balance field of an account's FlowToken Balance - -import FungibleToken from 0xFUNGIBLETOKENADDRESS -import ExampleToken from 0xTOKENADDRESS - -pub fun main(account: Address): UFix64 { - let acct = getAccount(account) - let vaultRef = acct.getCapability(/public/exampleTokenBalance)!.borrow<&ExampleToken.Vault{FungibleToken.Balance}>() - ?? panic("Could not borrow Balance reference to the Vault") - - return vaultRef.balance +// This script reads the balance field +// of an account's ExampleToken Balance + +import FungibleToken from 0x1 +import ExampleToken from 0x1 +import FungibleTokenMetadataViews from 0x1 + +access(all) fun main(address: Address): UFix64 { + let vaultData = ExampleToken.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not get vault data view for the contract") + + return getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>( + vaultData.metadataPath + )?.balance + ?? panic("Could not borrow Balance reference to the Vault") } `; @@ -47,4 +51,4 @@ export const getBalance = async (props = {}) => { reportMissing("arguments", args.length, 1, `getBalance =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getBlockOffset.js b/src/generated/scripts/getBlockOffset.js index ac60ba44..f8bc55c9 100644 --- a/src/generated/scripts/getBlockOffset.js +++ b/src/generated/scripts/getBlockOffset.js @@ -5,13 +5,13 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` import FlowManager from 0x01 -pub fun main():UInt64 { +access(all) fun main():UInt64 { return FlowManager.blockOffset } @@ -41,4 +41,4 @@ export const getBlockOffset = async (props = {}) => { reportMissing("arguments", args.length, 0, `getBlockOffset =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getContractAddress.js b/src/generated/scripts/getContractAddress.js index 5ff8b596..76d45886 100644 --- a/src/generated/scripts/getContractAddress.js +++ b/src/generated/scripts/getContractAddress.js @@ -5,21 +5,19 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` -import FlowManager from 0x01 - -pub fun main(name: String, managerAccount: Address):Address? { - let manager = getAccount(managerAccount) - let linkPath = FlowManager.contractManagerPath - let contractManager = manager - .getCapability(linkPath) - .borrow<&FlowManager.Mapper>()! - - return contractManager.getAddress(name) - +import FlowManager from 0x01 + +access(all) fun main(name: String, managerAccount: Address):Address? { + let manager = getAccount(managerAccount) + let linkPath = FlowManager.contractManagerPath + let contractManager = manager.capabilities.borrow<&FlowManager.Mapper>(linkPath)! + + return contractManager.getAddress(name) + } `; @@ -47,4 +45,4 @@ export const getContractAddress = async (props = {}) => { reportMissing("arguments", args.length, 2, `getContractAddress =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getManagerAddress.js b/src/generated/scripts/getManagerAddress.js index 94758757..918ab552 100644 --- a/src/generated/scripts/getManagerAddress.js +++ b/src/generated/scripts/getManagerAddress.js @@ -5,18 +5,17 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` -pub fun main(serviceAddress: Address): Address? { - let account = getAccount(serviceAddress) - let ref = account - .getCapability(/public/flowManagerAddress) - .borrow<&[Address]>()! - - return ref[0] -} +access(all) fun main(serviceAddress: Address): Address? { + let account = getAccount(serviceAddress) + + let ref = account.capabilities.borrow<&[Address]>(/public/flowManagerAddress)! + + return ref[0] +} `; @@ -44,4 +43,4 @@ export const getManagerAddress = async (props = {}) => { reportMissing("arguments", args.length, 1, `getManagerAddress =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/scripts/getTimestampOffset.js b/src/generated/scripts/getTimestampOffset.js index 46f48ea6..79ac8ee2 100644 --- a/src/generated/scripts/getTimestampOffset.js +++ b/src/generated/scripts/getTimestampOffset.js @@ -5,13 +5,13 @@ import { replaceImportAddresses, reportMissingImports, reportMissing, - executeScript } from '@onflow/flow-cadut' +import { executeScript } from '../../interaction' export const CODE = ` import FlowManager from 0x01 -pub fun main():UFix64 { +access(all) fun main():UFix64 { return FlowManager.timestampOffset } @@ -41,4 +41,4 @@ export const getTimestampOffset = async (props = {}) => { reportMissing("arguments", args.length, 0, `getTimestampOffset =>`); return executeScript({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/createAccount.js b/src/generated/transactions/createAccount.js index ab0ded5e..7bc5f294 100644 --- a/src/generated/transactions/createAccount.js +++ b/src/generated/transactions/createAccount.js @@ -9,27 +9,35 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -import FlowManager from 0x01 - -transaction (_ name: String?, pubKey: [String], manager: Address) { - prepare( admin: AuthAccount) { - let newAccount = AuthAccount(payer:admin) - for key in pubKey { - newAccount.addPublicKey(key.decodeHex()) - } - - if name != nil { - let linkPath = FlowManager.accountManagerPath - let accountManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! - - // Create a record in account database - let address = newAccount.address - accountManager.setAddress(name!, address: address) - } - } -} +import FlowManager from 0x01 + +transaction (_ name: String?, pubKey: [String], manager: Address) { + prepare( admin: auth(BorrowValue) &Account) { + let newAccount = Account(payer:admin) + for key in pubKey { + let keyData = RLP.decodeList(key.decodeHex()) + let rawSign = RLP.decodeString(keyData[1])[0] + let rawHash = RLP.decodeString(keyData[2])[0] + newAccount.keys.add( + publicKey: PublicKey( + publicKey: RLP.decodeString(keyData[0]), + signatureAlgorithm: SignatureAlgorithm(rawValue: rawSign)! + ), + hashAlgorithm: HashAlgorithm(rawValue: rawHash)!, + weight: UFix64(Int32.fromBigEndianBytes(RLP.decodeString(keyData[3]))!)! + ) + } + + if name != nil { + let linkPath = FlowManager.accountManagerPath + let accountManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! + + // Create a record in account database + let address = newAccount.address + accountManager.setAddress(name!, address: address) + } + } +} `; @@ -65,4 +73,4 @@ export const createAccount = async (props = {}) => { reportMissing("signers", signers.length, 1, `createAccount =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/deployContract.js b/src/generated/transactions/deployContract.js index 4fa0f1df..8eedfd8f 100644 --- a/src/generated/transactions/deployContract.js +++ b/src/generated/transactions/deployContract.js @@ -9,26 +9,24 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -import FlowManager from 0x01 - -transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { - prepare(acct: AuthAccount){ - let decoded = code.decodeHex() - acct.contracts.add( - name: name, - code: decoded, - ##ARGS-LIST## - ) - - let linkPath = FlowManager.contractManagerPath - let contractManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! - - let address = acct.address - contractManager.setAddress(name, address: address) - } -} +import FlowManager from 0x01 + +transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { + prepare(acct: auth(AddContract) &Account) { + let decoded = code.decodeHex() + acct.contracts.add( + name: name, + code: decoded, + ##ARGS-LIST## + ) + + let linkPath = FlowManager.contractManagerPath + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! + + let address = acct.address + contractManager.setAddress(name, address: address) + } +} `; @@ -64,4 +62,4 @@ export const deployContract = async (props = {}) => { reportMissing("signers", signers.length, 1, `deployContract =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/initManager.js b/src/generated/transactions/initManager.js index 0c3cba7d..02d35a3f 100644 --- a/src/generated/transactions/initManager.js +++ b/src/generated/transactions/initManager.js @@ -9,14 +9,14 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -transaction ( code: String ) { - prepare( admin: AuthAccount) { - admin.contracts.add( - name: "FlowManager", - code: code.decodeHex(), - ) - } -} +transaction ( code: String ) { + prepare( admin: &Account) { + admin.contracts.add( + name: "FlowManager", + code: code.decodeHex(), + ) + } +} `; @@ -52,4 +52,4 @@ export const initManager = async (props = {}) => { reportMissing("signers", signers.length, 1, `initManager =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/mintTokens.js b/src/generated/transactions/mintTokens.js index 97b714e8..16202ba9 100644 --- a/src/generated/transactions/mintTokens.js +++ b/src/generated/transactions/mintTokens.js @@ -9,22 +9,27 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -import FungibleToken from 0xFUNGIBLETOKENADDRESS -import ExampleToken from 0xTOKENADDRESS +import FungibleToken from 0x1 +import ExampleToken from 0x1 +import FungibleTokenMetadataViews from 0x1 transaction(recipient: Address, amount: UFix64) { - let tokenAdmin: &ExampleToken.Administrator + let tokenAdmin: &FlowToken.Administrator let tokenReceiver: &{FungibleToken.Receiver} + let supplyBefore: UFix64 - prepare(signer: AuthAccount) { - self.tokenAdmin = signer - .borrow<&ExampleToken.Administrator>(from: /storage/exampleTokenAdmin) - ?? panic("Signer is not the token admin") + prepare(signer: auth(BorrowValue) &Account) { + self.supplyBefore = ExampleToken.totalSupply - self.tokenReceiver = getAccount(recipient) - .getCapability(/public/exampleTokenReceiver)! - .borrow<&{FungibleToken.Receiver}>() - ?? panic("Unable to borrow receiver reference") + // Borrow a reference to the admin object + self.tokenAdmin = signer.storage.borrow<&ExampleToken.Administrator>(from: ExampleToken.AdminStoragePath) + ?? panic("Signer is not the token admin") + + let vaultData = ExampleToken.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not get vault data view for the contract") + + self.tokenReceiver = getAccount(recipient).capabilities.borrow<&{FungibleToken.Receiver}>(vaultData.receiverPath) + ?? panic("Could not borrow receiver reference to the Vault") } execute { @@ -35,6 +40,10 @@ transaction(recipient: Address, amount: UFix64) { destroy minter } + + post { + ExampleToken.totalSupply == self.supplyBefore + amount: "The total supply must be increased by the amount" + } } `; @@ -71,4 +80,4 @@ export const mintTokens = async (props = {}) => { reportMissing("signers", signers.length, 1, `mintTokens =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/registerContract.js b/src/generated/transactions/registerContract.js index d180f86b..d4672faf 100644 --- a/src/generated/transactions/registerContract.js +++ b/src/generated/transactions/registerContract.js @@ -9,17 +9,15 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -import FlowManager from 0x01 - -transaction(name: String, address: Address) { - prepare(signer: AuthAccount){ - let linkPath = FlowManager.contractManagerPath - let contractManager = signer - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! - contractManager.setAddress(name, address: address) - } -} +import FlowManager from 0x01 + +transaction(name: String, address: Address) { + prepare(signer: auth(BorrowValue) &Account){ + let linkPath = FlowManager.contractManagerPath + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! + contractManager.setAddress(name, address: address) + } +} `; @@ -55,4 +53,4 @@ export const registerContract = async (props = {}) => { reportMissing("signers", signers.length, 1, `registerContract =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/scratch.js b/src/generated/transactions/scratch.js index d9356980..8077fb48 100644 --- a/src/generated/transactions/scratch.js +++ b/src/generated/transactions/scratch.js @@ -9,10 +9,10 @@ import { } from '@onflow/flow-cadut' export const CODE = ` -transaction{ - prepare(acct: AuthAccount){ - log(acct.address) - } +transaction{ + prepare(acct: &Account){ + log(acct.address) + } } `; @@ -48,4 +48,4 @@ export const scratch = async (props = {}) => { reportMissing("signers", signers.length, 1, `scratch =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/setBlockOffset.js b/src/generated/transactions/setBlockOffset.js index 131d8f13..c90c605e 100644 --- a/src/generated/transactions/setBlockOffset.js +++ b/src/generated/transactions/setBlockOffset.js @@ -12,7 +12,7 @@ export const CODE = ` import FlowManager from 0x01 transaction(offset: UInt64){ - prepare(signer:AuthAccount){ + prepare(signer: &Account){ FlowManager.setBlockOffset(offset) } } @@ -51,4 +51,4 @@ export const setBlockOffset = async (props = {}) => { reportMissing("signers", signers.length, 1, `setBlockOffset =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/setTimestampOffset.js b/src/generated/transactions/setTimestampOffset.js index c0ddcdae..72a8af49 100644 --- a/src/generated/transactions/setTimestampOffset.js +++ b/src/generated/transactions/setTimestampOffset.js @@ -12,7 +12,7 @@ export const CODE = ` import FlowManager from 0x01 transaction(offset: UFix64){ - prepare(signer:AuthAccount){ + prepare(signer: &Account){ FlowManager.setTimestampOffset(offset) } } @@ -51,4 +51,4 @@ export const setTimestampOffset = async (props = {}) => { reportMissing("signers", signers.length, 1, `setTimestampOffset =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/generated/transactions/updateContract.js b/src/generated/transactions/updateContract.js index 9eec7fbd..ec136d0d 100644 --- a/src/generated/transactions/updateContract.js +++ b/src/generated/transactions/updateContract.js @@ -12,19 +12,21 @@ export const CODE = ` import FlowManager from 0x01 transaction(name:String, code: String, manager: Address ##ARGS-WITH-TYPES##) { - prepare(acct: AuthAccount){ + prepare(acct: auth(AddContract, UpdateContract) &Account){ let decoded = code.decodeHex() if acct.contracts.get(name: name) == nil { - acct.contracts.add(name: name, code: decoded) + acct.contracts.add( + name: name, + code: decoded, + ##ARGS-LIST## + ) } else { - acct.contracts.update__experimental(name: name, code: decoded) + acct.contracts.update(name: name, code: decoded) } let linkPath = FlowManager.contractManagerPath - let contractManager = getAccount(manager) - .getCapability(linkPath)! - .borrow<&FlowManager.Mapper>()! + let contractManager = getAccount(manager).capabilities.borrow<&FlowManager.Mapper>(linkPath)! let address = acct.address contractManager.setAddress(name, address: address) @@ -65,4 +67,4 @@ export const updateContract = async (props = {}) => { reportMissing("signers", signers.length, 1, `updateContract =>`); return sendTransaction({code, processed: true, ...props}) -} \ No newline at end of file +} diff --git a/src/interaction.js b/src/interaction.js index ad61c0e8..3ef4c298 100644 --- a/src/interaction.js +++ b/src/interaction.js @@ -162,6 +162,15 @@ export const sendTransaction = async (...props) => { return [result, err, logs] } +// TODO helper until flow-cadut is updated +const replaceAccessAllInScript = code => { + const scriptMatcher = /(pub|access\s*\(\s*all\s*\))\s+fun\s+main\s*/gimu + if (scriptMatcher.test(code)) { + return code.replace(scriptMatcher, "pub fun main") + } + return code +} + /** * Sends script code for execution. Returns decoded value * @param {Object} props @@ -179,11 +188,12 @@ export const executeScript = async (...props) => { try { const extractor = extractParameters("script") const {code, args, limit} = await extractor(_props) + const patchedCode = replaceAccessAllInScript(code) const ix = [fcl.script(code), fcl.limit(limit)] // add arguments if any if (args) { - const resolvedArgs = await resolveArguments(args, code) + const resolvedArgs = await resolveArguments(args, patchedCode) ix.push(fcl.args(resolvedArgs)) } const response = await fcl.send(ix) diff --git a/src/manager.js b/src/manager.js index 6189339c..d17daccc 100644 --- a/src/manager.js +++ b/src/manager.js @@ -53,7 +53,7 @@ export const getManagerAddress = async () => { const serviceAddress = await getServiceAddress(); const code = ` - pub fun main(address: Address):Bool { + access(all) fun main(address: Address):Bool { return getAccount(address).contracts.get("FlowManager") != null } `; diff --git a/src/storage.js b/src/storage.js index 69767522..898e7454 100644 --- a/src/storage.js +++ b/src/storage.js @@ -45,21 +45,6 @@ function formatReferences(paths) { const value = paths[path].type.type value.fullType = value.typeID - value.restrictionsList = new Set( - value.restrictions.map(item => { - return item.typeID - }) - ) - - // Extra methods to query restrictions - value.haveRestrictions = function (query) { - for (const item of value.restrictionsList) { - if (item.includes(query)) { - return true - } - } - return false - } acc[slot] = value @@ -75,23 +60,21 @@ function formatStorage(paths) { } function processValues(result) { const publicPaths = formatReferences(result.publicPaths) - const privatePaths = formatReferences(result.privatePaths) const storagePaths = formatStorage(result.storagePaths) - return {publicPaths, privatePaths, storagePaths} + return {publicPaths, storagePaths} } /** - * Retrieves information about the public, private, and storage paths for a given account. + * Retrieves information about the public and storage paths for a given account. * * @async * @param {string} account - The address or the name of the account to retrieve path information for. * @param {boolean} [useSet=true] - Whether to return array or Set * @returns {Promise<{ * publicPaths: string[] | Set, - * privatePaths: string[] | Set, * storagePaths: string[] | Set - * }>} An object containing arrays or Sets of the public, private, and storage paths for the account. + * }>} An object containing arrays or Sets of the public and storage paths for the account. */ export async function getPaths(account, useSet = true) { let accountAddress = account @@ -101,23 +84,20 @@ export async function getPaths(account, useSet = true) { const [result] = await executeScript({ code: ` - pub struct PathInfo{ - pub let public: [PublicPath] - pub let private: [PrivatePath] - pub let storage: [StoragePath] + access(all) struct PathInfo{ + access(all) let public: &[PublicPath] + access(all) let storage: &[StoragePath] - init(public: [PublicPath], private: [PrivatePath], storage: [StoragePath]){ + init(public: &[PublicPath], storage: &[StoragePath]){ self.public = public - self.private = private self.storage = storage } } - pub fun main(address: Address): PathInfo{ - let account = getAuthAccount(address) + access(all) fun main(address: Address): PathInfo{ + let account = getAccount(address) let info = PathInfo( - public: account.publicPaths, - private: account.privatePaths, - storage: account.storagePaths + public: account.storage.publicPaths, + storage: account.storage.storagePaths ) return info } @@ -127,21 +107,19 @@ export async function getPaths(account, useSet = true) { return { publicPaths: reduceValues(result.public, useSet), - privatePaths: reduceValues(result.private, useSet), storagePaths: reduceValues(result.storage, useSet), } } /** - * Retrieves public, private, and storage paths for a given account with extra information available on them + * Retrieves public and storage paths for a given account with extra information available on them * * @async * @param {string} account - The address of the account to retrieve path information for. * @returns {Promise<{ * publicPaths: {[key: string]: {[key: string]: any}}, - * privatePaths: {[key: string]: {[key: string]: any}}, * storagePaths: {[key: string]: {[key: string]: any}} - * }>} An object containing objects with the types of the public, private, and storage paths for the account. + * }>} An object containing objects with the types of the public and storage paths for the account. */ export async function getPathsWithType(account) { let accountAddress = account @@ -150,33 +128,26 @@ export async function getPathsWithType(account) { } const [result] = await executeScript({ code: ` - pub fun main(address: Address): {String: {String: AnyStruct}} { - let account = getAuthAccount(address) + access(all) fun main(address: Address): {String: {String: AnyStruct}} { + let account = getAccount(address) var res: {String: {String: AnyStruct}} = {} // Iterate over public let public: {String: AnyStruct} = {} - account.forEachPublic(fun (path:PublicPath, type: Type): Bool{ + account.storage.forEachPublic(fun (path:PublicPath, type: Type): Bool{ public[path.toString()] = type return true }) - // Iterate over public - let private: {String: AnyStruct} = {} - account.forEachPrivate(fun (path:PrivatePath, type: Type): Bool{ - private[path.toString()] = type - return true - }) // Iterate over storage paths let storage: {String: AnyStruct} = {} - account.forEachStored(fun (path:StoragePath, type: Type): Bool{ + account.storage.forEachStored(fun (path:StoragePath, type: Type): Bool{ storage[path.toString()] = type return true }) res["publicPaths"] = public - res["privatePaths"] = private res["storagePaths"] = storage return res @@ -204,33 +175,35 @@ export async function getStorageValue(account, path) { let fixedPath = path.startsWith("/") ? path.slice(1) : path let storagePath = `/storage/${fixedPath}` + // TODO I am unsure whether this is correct for MetadataViews/ViewResolver in V2 standard const code = ` import MetadataViews from 0x1 + import ViewResolver from 0x1 - pub fun main(address: Address, path: StoragePath): AnyStruct{ - let account = getAuthAccount(address) + access(all) fun main(address: Address, path: StoragePath): AnyStruct{ + let account = getAuthAccount< auth(BorrowValue) &Account>(address) - if let valueType = account.type(at: path) { + if let valueType = account.storage.type(at: path) { if(valueType.isSubtype(of: Type<@AnyResource>())){ - let obj = account.borrow< auth &AnyResource >(from: path)! - let meta = obj as? &AnyResource{MetadataViews.ResolverCollection} + let obj = account.storage.borrow< &AnyResource >(from: path)! + let meta = obj as? &{ViewResolver.ResolverCollection} if let idList = meta?.getIDs(){ if(idList.length > 0){ let res: {UInt64: AnyStruct} = {} for id in idList { - res[id] = meta!.borrowViewResolver(id: id).resolveView(Type())! + res[id] = meta!.borrowViewResolver(id: id)!.resolveView(Type())! } return res } } - let value = account.borrow< &AnyResource >(from: path)! as AnyStruct + let value = account.storage.borrow< &AnyResource >(from: path)! as AnyStruct return value } - let value = account.borrow< &AnyStruct >(from: path)! as AnyStruct + let value = account.storage.borrow< &AnyStruct >(from: path)! as AnyStruct return value } @@ -262,12 +235,12 @@ export async function getStorageStats(address, convert = true) { const [result] = await executeScript({ code: ` - pub fun main(address: Address): {String: UInt64} { - let account = getAuthAccount(address) + access(all) fun main(address: Address): {String: UInt64} { + let account = getAccount(address) return { - "used": account.storageUsed, - "capacity": account.storageCapacity + "used": account.storage.used, + "capacity": account.storage.capacity } } `, diff --git a/src/templates.js b/src/templates.js index ba633364..63bf60a5 100644 --- a/src/templates.js +++ b/src/templates.js @@ -19,15 +19,23 @@ import registry from "./generated" import {defaultsByName} from "./file" -const FlowTokenMap = {ExampleToken: defaultsByName.FlowToken} +const FlowTokenMap = { + ExampleToken: defaultsByName.FlowToken, + FungibleTokenMetadataViews: defaultsByName.FungibleTokenMetadataViews, +} const lowerFirst = name => { return name[0].toLowerCase() + name.slice(1) } export const makeMintTransaction = async name => { - const code = await registry.transactions.mintTokensTemplate(FlowTokenMap) + let code = await registry.transactions.mintTokensTemplate(FlowTokenMap) const pattern = /(ExampleToken)/gi + const aspPattern = /ExampleToken.AdminStoragePath/gi + + if (name === "FlowToken") { + code = code.replace(aspPattern, "/storage/flowTokenAdmin") + } return code.replace(pattern, match => { return match === "ExampleToken" ? name : lowerFirst(name) diff --git a/test/basic/cadence.test.js b/test/basic/cadence.test.js index 03a77ff2..194de098 100644 --- a/test/basic/cadence.test.js +++ b/test/basic/cadence.test.js @@ -5,6 +5,6 @@ describe("manager code", () => { test("FlowManager contract", async () => { const code = await FlowManagerTemplate() - expect(code.includes("pub contract FlowManager")).toBe(true) + expect(code.includes("access(all) contract FlowManager")).toBe(true) }) }) diff --git a/test/cadence/contracts/HelloWorld.cdc b/test/cadence/contracts/HelloWorld.cdc index 730067dc..f1fe57b3 100644 --- a/test/cadence/contracts/HelloWorld.cdc +++ b/test/cadence/contracts/HelloWorld.cdc @@ -1,8 +1,8 @@ -pub contract HelloWorld{ - pub let message: String +access(all) contract HelloWorld{ + access(all) let message: String init(){ log("contract added to account") self.message = "Hello, from Cadence" } -} \ No newline at end of file +} diff --git a/test/cadence/contracts/utility/Message.cdc b/test/cadence/contracts/utility/Message.cdc index 89000e2f..ab1c855d 100644 --- a/test/cadence/contracts/utility/Message.cdc +++ b/test/cadence/contracts/utility/Message.cdc @@ -1,7 +1,7 @@ -pub contract Message{ - pub let data: String +access(all) contract Message{ + access(all) let data: String init(){ self.data = "This is Message contract" } -} \ No newline at end of file +} diff --git a/test/cadence/scripts/get-message.cdc b/test/cadence/scripts/get-message.cdc index 94abdbfd..5f6a10e6 100644 --- a/test/cadence/scripts/get-message.cdc +++ b/test/cadence/scripts/get-message.cdc @@ -1,5 +1,5 @@ import HelloWorld from 0x01 -pub fun main():String{ +access(all) fun main():String{ return HelloWorld.message -} \ No newline at end of file +} diff --git a/test/cadence/scripts/log-message.cdc b/test/cadence/scripts/log-message.cdc index a6238df5..4e0d1af7 100644 --- a/test/cadence/scripts/log-message.cdc +++ b/test/cadence/scripts/log-message.cdc @@ -1,4 +1,4 @@ -pub fun main(): Int{ +access(all) fun main(): Int{ log("hello from cadence") return 42 -} \ No newline at end of file +} diff --git a/test/cadence/scripts/log-passed-message.cdc b/test/cadence/scripts/log-passed-message.cdc index 755433de..030eac89 100644 --- a/test/cadence/scripts/log-passed-message.cdc +++ b/test/cadence/scripts/log-passed-message.cdc @@ -1,4 +1,4 @@ -pub fun main(message: String):String{ +access(all) fun main(message: String):String{ log(message) return message -} \ No newline at end of file +} diff --git a/test/cadence/scripts/read-mocked-block-offset.cdc b/test/cadence/scripts/read-mocked-block-offset.cdc index b1a616dd..0972b5ad 100644 --- a/test/cadence/scripts/read-mocked-block-offset.cdc +++ b/test/cadence/scripts/read-mocked-block-offset.cdc @@ -1,6 +1,6 @@ import FlowManager from 0x01 -pub fun main(): UInt64 { +access(all) fun main(): UInt64 { let mockedHeight = FlowManager.getBlockHeight(); let realHeight = getCurrentBlock().height; log("Mocked Height: ".concat(mockedHeight.toString())) diff --git a/test/cadence/scripts/read-mocked-timestamp-offset.cdc b/test/cadence/scripts/read-mocked-timestamp-offset.cdc index 0009f0bb..72dd1f7c 100644 --- a/test/cadence/scripts/read-mocked-timestamp-offset.cdc +++ b/test/cadence/scripts/read-mocked-timestamp-offset.cdc @@ -1,6 +1,6 @@ import FlowManager from 0x01 -pub fun main(): UFix64 { +access(all) fun main(): UFix64 { let mockedTimestamp = FlowManager.getBlockTimestamp(); let realTimestamp = getCurrentBlock().timestamp; log("Mocked Height: ".concat(mockedTimestamp.toString())) diff --git a/test/cadence/transactions/log-message.cdc b/test/cadence/transactions/log-message.cdc index 10cae652..1766b12b 100644 --- a/test/cadence/transactions/log-message.cdc +++ b/test/cadence/transactions/log-message.cdc @@ -1,5 +1,5 @@ transaction(message:String){ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log(message) } -} \ No newline at end of file +} diff --git a/test/cadence/transactions/log-signer-address.cdc b/test/cadence/transactions/log-signer-address.cdc index 9ff9b0dd..9a8fa3c2 100644 --- a/test/cadence/transactions/log-signer-address.cdc +++ b/test/cadence/transactions/log-signer-address.cdc @@ -1,5 +1,5 @@ transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log("Signer Address:".concat(signer.address.toString())) } -} \ No newline at end of file +} diff --git a/test/integration/account.test.js b/test/integration/account.test.js index 014ae968..29b53a4e 100644 --- a/test/integration/account.test.js +++ b/test/integration/account.test.js @@ -13,8 +13,9 @@ import {playgroundImport} from "../../src/transformers" import {isAddress} from "../../src" import {validateKeyPair} from "../util/validate-key-pair" import {permute} from "../util/permute" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" -jest.setTimeout(30000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) beforeEach(async () => { const basePath = path.resolve(__dirname, "../cadence") @@ -116,7 +117,7 @@ it("getAccountAddress - should return proper playground addresses", async () => } const code = ` - pub fun main(address:Address):Address{ + access(all) fun main(address:Address):Address{ return getAccount(address).address } ` diff --git a/test/integration/deploy.test.js b/test/integration/deploy.test.js index 685f71aa..fc5d1c43 100644 --- a/test/integration/deploy.test.js +++ b/test/integration/deploy.test.js @@ -11,9 +11,10 @@ import { shallPass, shallResolve, } from "../../src" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" // We need to set timeout for a higher number, cause some transactions might take up some time -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) describe("interactions - sendTransaction", () => { // Instantiate emulator and path to Cadence files @@ -73,7 +74,7 @@ describe("interactions - sendTransaction", () => { code: ` import HelloWorld from 0x1 - pub fun main():String{ + access(all) fun main():String{ return HelloWorld.message } `, @@ -88,9 +89,9 @@ describe("interactions - sendTransaction", () => { await shallPass( deployContract({ code: ` - pub contract Basic{ - pub let message: String - pub let number: Int + access(all) contract Basic{ + access(all) let message: String + access(all) let number: Int init(message: String, number: Int){ self.message = message self.number = number @@ -107,7 +108,7 @@ describe("interactions - sendTransaction", () => { code: ` import Basic from 0x1 - pub fun main():String{ + access(all) fun main():String{ return Basic.message } `, @@ -122,7 +123,7 @@ describe("interactions - sendTransaction", () => { code: ` import Basic from 0x1 - pub fun main():Int{ + access(all) fun main():Int{ return Basic.number } `, diff --git a/test/integration/imports.test.js b/test/integration/imports.test.js index b6127169..90dbf947 100644 --- a/test/integration/imports.test.js +++ b/test/integration/imports.test.js @@ -7,11 +7,12 @@ import { getServiceAddress, } from "../../src" import {defaultsByName} from "../../src/file" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) const emptyContract = name => - `pub contract ${name}{ + `access(all) contract ${name}{ init(){} } ` @@ -40,7 +41,7 @@ describe("import resolver", () => { import FungibleToken from 0xFUNGIBLETOKEN import FlowToken from 0xFLOWTOKEN - pub fun main(){} + access(all) fun main(){} ` const addressMap = await resolveImports(code) diff --git a/test/integration/interaction.test.js b/test/integration/interaction.test.js index a3dc9c87..280558dd 100644 --- a/test/integration/interaction.test.js +++ b/test/integration/interaction.test.js @@ -19,9 +19,10 @@ import { } from "../../src" import {permute} from "../util/permute" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" // We need to set timeout for a higher number, cause some transactions might take up some time -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) describe("interactions - sendTransaction", () => { // Instantiate emulator and path to Cadence files @@ -59,7 +60,7 @@ describe("interactions - sendTransaction", () => { await shallPass(async () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log(signer.address) } } @@ -72,7 +73,7 @@ describe("interactions - sendTransaction", () => { const [, , logs] = await shallPass(async () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log("hello world") } } @@ -87,7 +88,7 @@ describe("interactions - sendTransaction", () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ assert(signer.address == ${Alice}, message: "Signer address must be equal to Alice's Address") } } @@ -102,7 +103,7 @@ describe("interactions - sendTransaction", () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ assert(signer.address == ${Alice}, message: "Signer address must be equal to Alice's Address") } } @@ -122,7 +123,7 @@ describe("interactions - sendTransaction", () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ assert(signer.address == ${Alice}, message: "Signer address must be equal to Alice's Address") } } @@ -158,7 +159,7 @@ describe("interactions - sendTransaction", () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ assert(signer.address == ${Adam}, message: "Signer address must be equal to Adam's Address") } } @@ -196,7 +197,7 @@ describe("interactions - sendTransaction", () => { const code = ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ assert(signer.address == ${Adam}, message: "Signer address must be equal to Adam's Address") } } @@ -218,7 +219,7 @@ describe("interactions - sendTransaction", () => { await shallPass(async () => { const code = ` transaction(a: Int){ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log(signer.address) } } @@ -232,7 +233,7 @@ describe("interactions - sendTransaction", () => { await shallPass(async () => { const code = ` transaction(a: Int, b: Int, name: String){ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log(signer.address) } } @@ -246,7 +247,7 @@ describe("interactions - sendTransaction", () => { await shallPass(async () => { const code = ` transaction(a: Int, b: Int, name: String){ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ log(signer.address) } } @@ -312,7 +313,7 @@ describe("interactions - executeScript", () => { test("executeScript - shall pass with code provided", async () => { await shallResolve(async () => { const code = ` - pub fun main(){ + access(all) fun main(){ log("hello from cadence") } ` @@ -323,7 +324,7 @@ describe("interactions - executeScript", () => { test("executeScript - shall capture logs", async () => { const [, , logs] = await shallResolve(async () => { const code = ` - pub fun main():Int{ + access(all) fun main():Int{ log("hello from cadence") log("this second log has been captured!") @@ -358,7 +359,7 @@ describe("interactions - executeScript", () => { test("executeScript - shall work properly for empty array as argument", async () => { const [result, err] = await shallResolve(async () => { const code = ` - pub fun main(data: [String]): [String]{ + access(all) fun main(data: [String]): [String]{ log(data) return data } diff --git a/test/integration/metadata.test.js b/test/integration/metadata.test.js index 3703409b..e01f1c5f 100644 --- a/test/integration/metadata.test.js +++ b/test/integration/metadata.test.js @@ -1,7 +1,8 @@ import path from "path" import {init, emulator, executeScript, shallResolve} from "../../src" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) describe("metadata examples", () => { beforeEach(async () => { @@ -16,7 +17,7 @@ describe("metadata examples", () => { test("simple dictionary - {String: String}", async () => { const code = ` - pub fun main(metadata: {String: String}): String{ + access(all) fun main(metadata: {String: String}): String{ return metadata["name"]! } ` @@ -28,7 +29,7 @@ describe("metadata examples", () => { test("simple dictionary - {String: Int}", async () => { const code = ` - pub fun main(metadata: {String: Int}): Int{ + access(all) fun main(metadata: {String: Int}): Int{ return metadata["answer"]! } ` @@ -40,7 +41,7 @@ describe("metadata examples", () => { test("simple array - [String]", async () => { const code = ` - pub fun main(list: [String]): String{ + access(all) fun main(list: [String]): String{ return list[0] } ` @@ -52,7 +53,7 @@ describe("metadata examples", () => { test("nested arrays - [[Int]]", async () => { const code = ` - pub fun main(list: [[Int]], index: Int): Int { + access(all) fun main(list: [[Int]], index: Int): Int { log("this is log message we want to output") log(list[0][0]) log(list[0][1]) diff --git a/test/integration/storage.test.js b/test/integration/storage.test.js index a93d4b67..86c9c7c3 100644 --- a/test/integration/storage.test.js +++ b/test/integration/storage.test.js @@ -32,15 +32,13 @@ afterEach(async () => { describe("Storage Inspection", () => { test("Paths inspection", async () => { const Alice = await getAccountAddress("Alice") - const {publicPaths, privatePaths, storagePaths} = await getPaths(Alice) + const {publicPaths, storagePaths} = await getPaths(Alice) // Newly created account shall have 2 public and 1 storage slot occupied for FLOW Vault expect(publicPaths.size).toBe(2) expect(publicPaths.has("flowTokenBalance")).toBe(true) expect(publicPaths.has("flowTokenReceiver")).toBe(true) - expect(privatePaths.size).toBe(0) - expect(storagePaths.size).toBe(1) expect(storagePaths.has("flowTokenVault")).toBe(true) }) @@ -50,8 +48,8 @@ describe("Storage Inspection", () => { sendTransaction({ code: ` transaction{ - prepare(signer: AuthAccount){ - signer.save(42, to: /storage/answer) + prepare(signer: auth(SaveValue) &Account){ + signer.storage.save(42, to: /storage/answer) } } `, @@ -74,13 +72,6 @@ describe("Storage Inspection", () => { const refTokenBalance = publicPaths.flowTokenBalance expect(refTokenBalance).not.toBe(undefined) - expect( - refTokenBalance.restrictionsList.has( - "A.ee82856bf20e2aa6.FungibleToken.Balance" - ) - ).toBe(true) - expect(refTokenBalance.restrictionsList.size).toBe(1) - expect(refTokenBalance.haveRestrictions("FungibleToken.Balance")).toBe(true) }) test("Read storage stats", async () => { const {capacity, used} = await getStorageStats("Alice") @@ -104,8 +95,8 @@ describe("Storage Inspection", () => { sendTransaction({ code: ` transaction{ - prepare(signer: AuthAccount){ - signer.save(${expectedValue}, to: /storage/${pathName}) + prepare(signer: auth(SaveValue) &Account){ + signer.storage.save(${expectedValue}, to: /storage/${pathName}) } } `, diff --git a/test/integration/transformers.test.js b/test/integration/transformers.test.js index f89d0b56..2a97d83c 100644 --- a/test/integration/transformers.test.js +++ b/test/integration/transformers.test.js @@ -16,7 +16,7 @@ describe("transformers", () => { it("should inject contract for built-in methods", async () => { const code = ` - pub fun main() : UInt64 { + access(all) fun main() : UInt64 { return getCurrentBlock().height } ` diff --git a/test/integration/usage.test.js b/test/integration/usage.test.js index aa756af0..ca59f0d1 100644 --- a/test/integration/usage.test.js +++ b/test/integration/usage.test.js @@ -16,9 +16,10 @@ import { shallThrow, getServiceAddress, } from "../../src" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" // We need to set timeout for a higher number, because some transactions might take up some time -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) describe("Basic Usage test", () => { // Instantiate emulator and path to Cadence files @@ -47,8 +48,8 @@ describe("Basic Usage test", () => { ) expect(message).toBe("Hello, from Cadence") - await mintFlow(Alice, "13.37") - const [balance] = await getFlowBalance(Alice) + await shallPass(mintFlow(Alice, "13.37")) + const [balance] = await shallResolve(getFlowBalance(Alice)) expect(balance).toBe("13.37100000") }) @@ -65,7 +66,7 @@ describe("Basic Usage test", () => { code: ` import Message from 0x01 - pub fun main():String{ + access(all) fun main():String{ return Message.data } `, @@ -92,7 +93,7 @@ describe("jest methods", () => { sendTransaction({ code: ` transaction{ - prepare(signer: AuthAccount){ + prepare(signer: &Account){ panic("not on my watch!") } } @@ -105,7 +106,7 @@ describe("jest methods", () => { const [result, err] = await shallResolve( executeScript({ code: ` - pub fun main(): Int{ + access(all) fun main(): Int{ return 42 } `, @@ -120,7 +121,7 @@ describe("jest methods", () => { sendTransaction({ code: ` transaction{ - prepare(signer: AuthAccount){} + prepare(signer: &Account){} } `, }) @@ -131,7 +132,7 @@ describe("jest methods", () => { await shallThrow( executeScript({ code: ` - pub fun main(){ + access(all) fun main(){ panic("exit here") } `, @@ -157,7 +158,7 @@ describe("Path arguments", () => { const [result] = await shallResolve( executeScript({ code: ` - pub fun main(): Bool{ + access(all) fun main(): Bool{ let path = StoragePath(identifier: "foo") log(path) @@ -173,7 +174,7 @@ describe("Path arguments", () => { const [result] = await shallResolve( executeScript({ code: ` - pub fun main(path: Path): Bool{ + access(all) fun main(path: Path): Bool{ log("this is awesome") log(path) @@ -190,7 +191,7 @@ describe("Path arguments", () => { const [result] = await shallResolve( executeScript({ code: ` - pub fun main(): Bool{ + access(all) fun main(): Bool{ return true } `, diff --git a/test/integration/utilities.test.js b/test/integration/utilities.test.js index 3a71f1b3..2d273b5e 100644 --- a/test/integration/utilities.test.js +++ b/test/integration/utilities.test.js @@ -22,9 +22,10 @@ import { } from "../../src/transformers" import * as manager from "../../src/manager" import {query} from "@onflow/fcl" +import {DEFAULT_TEST_TIMEOUT} from "../util/timeout.const" // We need to set timeout for a higher number, cause some transactions might take up some time -jest.setTimeout(10000) +jest.setTimeout(DEFAULT_TEST_TIMEOUT) describe("block height offset", () => { // Instantiate emulator and path to Cadence files @@ -76,8 +77,8 @@ describe("block height offset", () => { await shallPass( deployContract({ code: ` - pub contract BlockTest { - pub fun currentHeight(): UInt64 { + access(all) contract BlockTest { + access(all) fun currentHeight(): UInt64 { return getCurrentBlock().height } @@ -92,7 +93,7 @@ describe("block height offset", () => { const realBlock = await query({ cadence: ` - pub fun main(): UInt64 { + access(all) fun main(): UInt64 { return getCurrentBlock().height } `, @@ -102,7 +103,7 @@ describe("block height offset", () => { executeScript({ code: ` import BlockTest from 0x01 - pub fun main(): UInt64 { + access(all) fun main(): UInt64 { return BlockTest.currentHeight() } `, @@ -195,8 +196,8 @@ describe("timestamp offset", () => { await shallPass( deployContract({ code: ` - pub contract TimestampTest { - pub fun currentTime(): UFix64 { + access(all) contract TimestampTest { + access(all) fun currentTime(): UFix64 { return getCurrentBlock().timestamp } @@ -211,7 +212,7 @@ describe("timestamp offset", () => { const realTimestamp = await query({ cadence: ` - pub fun main(): UFix64 { + access(all) fun main(): UFix64 { return getCurrentBlock().timestamp } `, @@ -221,7 +222,7 @@ describe("timestamp offset", () => { executeScript({ code: ` import TimestampTest from 0x01 - pub fun main(): UFix64 { + access(all) fun main(): UFix64 { return TimestampTest.currentTime() } `, @@ -305,7 +306,7 @@ describe("transformers and injectors", () => { it("should inject built in mock", async () => { const props = { code: ` - pub fun main(){ + access(all) fun main(){ log(getCurrentBlock().height); } `, @@ -320,7 +321,7 @@ describe("transformers and injectors", () => { const accounts = ["Alice", "Bob", "Charlie", "Dave", "Eve"] const props = { code: ` - pub fun main(){ + access(all) fun main(){ let Alice = getAccount(0x01) let Bob = getAccount(0x02) let Charlie = getAccount(0x03) @@ -344,7 +345,7 @@ describe("transformers and injectors", () => { const accounts = ["Alice", "Bob", "Charlie", "Dave", "Eve"] const props = { code: ` - pub fun main(address:Address):Address{ + access(all) fun main(address:Address):Address{ return getAccount(address).address } `, diff --git a/test/util/timeout.const.js b/test/util/timeout.const.js new file mode 100644 index 00000000..76d3ba73 --- /dev/null +++ b/test/util/timeout.const.js @@ -0,0 +1 @@ +export const DEFAULT_TEST_TIMEOUT = 10000 From 55fea91b95954aa88a8bc0bcf0e3070c139dbacb Mon Sep 17 00:00:00 2001 From: NtTestAlert <50535142+NtTestAlert@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:34:32 +0100 Subject: [PATCH 2/7] fix: run flow-c1 instead of flow by default --- src/emulator/emulator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/emulator/emulator.js b/src/emulator/emulator.js index 607c3766..755282a7 100644 --- a/src/emulator/emulator.js +++ b/src/emulator/emulator.js @@ -43,6 +43,8 @@ export class Emulator { this.logging = false this.filters = [] this.logger = new Logger() + // TODO change to "flow" when no longer using c1 cli by default + this.execName = "flow-c1" } /** @@ -73,6 +75,7 @@ export class Emulator { * @param {number} [options.restPort] - Hardcoded REST/HTTP port * @param {number} [options.adminPort] - Hardcoded admin port * @param {number} [options.debuggerPort] - Hardcoded debug port + * @param {string} [options.execName] - Name of executable for flow-cli * @returns Promise<*> */ async start(options = {}) { @@ -105,13 +108,14 @@ More info: https://github.com/onflow/flow-js-testing/blob/master/TRANSITIONS.md# this.grpcPort = DEFAULT_GRPC_PORT + offset } - const {flags, logging = false, signatureCheck = false} = options + const {flags, logging = false, signatureCheck = false, execName} = options + if (execName) this.execName = execName // config access node config().put("accessNode.api", `http://localhost:${this.restPort}`) this.logging = logging - this.process = spawn("flow", [ + this.process = spawn(this.execName, [ "emulator", "--verbose", `--log-format=JSON`, From e1ca3216f201401dd38647cdb614fcc152d7711d Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 26 Mar 2024 15:49:00 -0700 Subject: [PATCH 3/7] update CI --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5bd852b2..d0e332e2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,7 +35,7 @@ jobs: - name: Get Flow CLI version id: testbed run: | - echo "flow-version=$(echo | flow version | grep 'Version' | sed 's/[^0-9\.]*//g')" >> $GITHUB_OUTPUT + echo "flow-version=$(echo | flow-c1 version | grep 'Version' | sed 's/[^0-9\.]*//g')" >> $GITHUB_OUTPUT echo "package-version=$(grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT echo "fcl-version=$(grep 'fcl":' package.json | sed 's/.*"@onflow\/fcl": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT From 4325e835a9c12b65cd5cb01d839aee868b89e3c6 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 26 Mar 2024 15:58:37 -0700 Subject: [PATCH 4/7] fix CI --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d0e332e2..12bdf8f5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,7 +35,7 @@ jobs: - name: Get Flow CLI version id: testbed run: | - echo "flow-version=$(echo | flow-c1 version | grep 'Version' | sed 's/[^0-9\.]*//g')" >> $GITHUB_OUTPUT + echo "flow-version=$(echo | flow-c1 version | grep 'Version:' | grep -oEi '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?')" >> $GITHUB_OUTPUT echo "package-version=$(grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT echo "fcl-version=$(grep 'fcl":' package.json | sed 's/.*"@onflow\/fcl": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT From 9da7bc43c96284747ab81c7797dc0ca188b161b9 Mon Sep 17 00:00:00 2001 From: NtTestAlert <50535142+NtTestAlert@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:15:24 +0100 Subject: [PATCH 5/7] fix CI, test authorized signers --- .github/workflows/pull-request.yml | 2 +- test/cadence/transactions/log-signer-address.cdc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 12bdf8f5..2b8c0290 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,7 +35,7 @@ jobs: - name: Get Flow CLI version id: testbed run: | - echo "flow-version=$(echo | flow-c1 version | grep 'Version:' | grep -oEi '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?')" >> $GITHUB_OUTPUT + echo "flow-version=$(echo | flow-c1 version --output json | grep 'Version:' | grep -oEi '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?')" >> $GITHUB_OUTPUT echo "package-version=$(grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT echo "fcl-version=$(grep 'fcl":' package.json | sed 's/.*"@onflow\/fcl": "\(.*\)".*/\1/')" >> $GITHUB_OUTPUT diff --git a/test/cadence/transactions/log-signer-address.cdc b/test/cadence/transactions/log-signer-address.cdc index 9a8fa3c2..c2636eb8 100644 --- a/test/cadence/transactions/log-signer-address.cdc +++ b/test/cadence/transactions/log-signer-address.cdc @@ -1,5 +1,5 @@ transaction{ - prepare(signer: &Account){ + prepare(signer: auth(BorrowValue, Capabilities) &Account){ log("Signer Address:".concat(signer.address.toString())) } } From 1ec1d5c4a3737060bea8ede815ea44786504d8fb Mon Sep 17 00:00:00 2001 From: NtTestAlert <50535142+NtTestAlert@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:25:03 +0100 Subject: [PATCH 6/7] fix shorthand imports --- src/file.js | 6 ++++-- src/imports.js | 18 +++++++++++++++++- test/integration/imports.test.js | 10 +++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/file.js b/src/file.js index 823e21dc..931195d5 100644 --- a/src/file.js +++ b/src/file.js @@ -20,11 +20,13 @@ import fs from "fs" import path from "path" import {config} from "@onflow/fcl" -import {replaceImportAddresses} from "./imports" +import {fixShorthandImports, replaceImportAddresses} from "./imports" import {isObject} from "./utils" export const readFile = path => { - return fs.readFileSync(path, "utf8") + const code = fs.readFileSync(path, "utf8") + // TODO remove once flow-cadut is updated to support short-hand imports + return fixShorthandImports(code) } /** diff --git a/src/imports.js b/src/imports.js index 31491875..998941b0 100644 --- a/src/imports.js +++ b/src/imports.js @@ -20,6 +20,22 @@ import {getContractAddress} from "./contract" import {defaultsByName} from "./file" import {replaceImportAddresses, extractImports} from "@onflow/flow-cadut" +// TODO remove once flow-cadut is updated to support short-hand imports +const importTokenPart = `(?:"[\\w\\d]+?")|(?:[\\w\\d]+)` +const importRegex = new RegExp( + `(^\\s*import\\s+)((?:${importTokenPart}[^\\n]*?,?[^\\n]?)+)[^\\n]*?(from)?[^\\n]*?$`, + "gium" +) +export const fixShorthandImports = code => { + return code.replaceAll(importRegex, found => { + if (found.indexOf(" from") !== -1) return found + const whatMatch = found.matchAll(/"?([^"\s]+)"?,?\s*?/giu) + return [...whatMatch] + .map(what => `import ${what[1]} from "./${what[1]}.cdc"`) + .join("\n") + }) +} + /** * Resolves import addresses defined in code template * @param {string} code - Cadence template code. @@ -27,7 +43,7 @@ import {replaceImportAddresses, extractImports} from "@onflow/flow-cadut" */ export const resolveImports = async code => { const addressMap = {} - const importList = extractImports(code) + const importList = extractImports(fixShorthandImports(code)) for (const key in importList) { if (defaultsByName[key]) { addressMap[key] = defaultsByName[key] diff --git a/test/integration/imports.test.js b/test/integration/imports.test.js index 90dbf947..ef3471b5 100644 --- a/test/integration/imports.test.js +++ b/test/integration/imports.test.js @@ -33,10 +33,15 @@ describe("import resolver", () => { test("use imports", async () => { await deployContract({code: emptyContract("First"), name: "First"}) await deployContract({code: emptyContract("Second"), name: "Second"}) + await deployContract({code: emptyContract("Third"), name: "Third"}) + await deployContract({code: emptyContract("A"), name: "A"}) + await deployContract({code: emptyContract("B"), name: "B"}) const code = ` import First from 0xFIRST import Second from 0xSECOND + import "Third" + import "A", "B" import FungibleToken from 0xFUNGIBLETOKEN import FlowToken from 0xFLOWTOKEN @@ -47,9 +52,12 @@ describe("import resolver", () => { const addressMap = await resolveImports(code) const Registry = await getServiceAddress() - const {First, Second, FungibleToken, FlowToken} = addressMap + const {First, Second, Third, A, B, FungibleToken, FlowToken} = addressMap expect(First).toBe(Registry) expect(Second).toBe(Registry) + expect(Third).toBe(Registry) + expect(A).toBe(Registry) + expect(B).toBe(Registry) expect(FungibleToken).toBe(defaultsByName.FungibleToken) expect(FlowToken).toBe(defaultsByName.FlowToken) }) From 081ceff1a27210bcd21d861f815fab8507c35d8e Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 1 Apr 2024 20:37:16 -0700 Subject: [PATCH 7/7] Update flow-cadut --- .gitignore | 1 + package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 05d339b4..fa37dd72 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules dist .DS_Store +coverage \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 286323c1..6693327a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@onflow/fcl": "^1.3.2", "@onflow/fcl-config": "^0.0.1", - "@onflow/flow-cadut": "0.2.0-alpha.9", + "@onflow/flow-cadut": "^0.3.0-stable-cadence.0", "@onflow/types": "^1.0.5", "elliptic": "^6.5.4", "esm": "^3.2.25", @@ -2806,9 +2806,9 @@ } }, "node_modules/@onflow/flow-cadut": { - "version": "0.2.0-alpha.9", - "resolved": "https://registry.npmjs.org/@onflow/flow-cadut/-/flow-cadut-0.2.0-alpha.9.tgz", - "integrity": "sha512-eFKt/0inM7hyWLMnCyNojQ/oaueij5HEP9xJNlnoa3q3+qJCCb2Wr8FQxebGtrGM4z3IaAb9ah7X13q0TeBRgg==", + "version": "0.3.0-stable-cadence.0", + "resolved": "https://registry.npmjs.org/@onflow/flow-cadut/-/flow-cadut-0.3.0-stable-cadence.0.tgz", + "integrity": "sha512-4HXt6m74T2CjGYVCyug8fgAv4Rxki0Tf6kUK01eByZNUUQkTGuC/RRjcUaBpUCCGwDoPXxospZAZds023hbDgw==", "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/config": "0.0.2", @@ -16596,9 +16596,9 @@ "integrity": "sha512-umvYsAwejX2yGJ5OFxM1dEaKmFEXf+34f4rJfVkfEYztgJqLkUbBkEB8HQsI8M78QUpWkWuNArqwbFvFerBbHA==" }, "@onflow/flow-cadut": { - "version": "0.2.0-alpha.9", - "resolved": "https://registry.npmjs.org/@onflow/flow-cadut/-/flow-cadut-0.2.0-alpha.9.tgz", - "integrity": "sha512-eFKt/0inM7hyWLMnCyNojQ/oaueij5HEP9xJNlnoa3q3+qJCCb2Wr8FQxebGtrGM4z3IaAb9ah7X13q0TeBRgg==", + "version": "0.3.0-stable-cadence.0", + "resolved": "https://registry.npmjs.org/@onflow/flow-cadut/-/flow-cadut-0.3.0-stable-cadence.0.tgz", + "integrity": "sha512-4HXt6m74T2CjGYVCyug8fgAv4Rxki0Tf6kUK01eByZNUUQkTGuC/RRjcUaBpUCCGwDoPXxospZAZds023hbDgw==", "requires": { "@babel/runtime": "^7.18.6", "@onflow/config": "0.0.2", diff --git a/package.json b/package.json index c904fbd9..ae00fe98 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "dependencies": { "@onflow/fcl": "^1.3.2", "@onflow/fcl-config": "^0.0.1", - "@onflow/flow-cadut": "0.2.0-alpha.9", + "@onflow/flow-cadut": "^0.3.0-stable-cadence.0", "@onflow/types": "^1.0.5", "elliptic": "^6.5.4", "esm": "^3.2.25",