-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Node, Universal, MemoryAccount } from '../../es/index.mjs' | ||
|
||
const contractSource = ` | ||
contract Test = | ||
entrypoint getArg(x : map(string, int)) = x | ||
`; | ||
|
||
(async () => { | ||
const node = await Node({ url: 'https://testnet.aeternity.io' }) | ||
const sdk = await Universal({ | ||
nodes: [{ name: 'testnet', instance: node }], | ||
compilerUrl: 'https://compiler.aepps.com', | ||
accounts: [MemoryAccount({ | ||
keypair: { | ||
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR', | ||
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b' | ||
} | ||
})] | ||
}) | ||
|
||
console.log('Height:', await sdk.height()) | ||
console.log('Instanceof works correctly for nodes pool', sdk.pool instanceof Map) | ||
|
||
const contract = await sdk.getContractInstance({ source: contractSource }) | ||
const deployInfo = await contract.deploy() | ||
console.log('Contract deployed at', deployInfo.address) | ||
const map = new Map([['foo', 42], ['bar', 43]]) | ||
const { decodedResult } = await contract.methods.getArg(map) | ||
console.log('Call result', decodedResult) | ||
console.log('Instanceof works correctly for returned map', decodedResult instanceof Map) | ||
})() |