@aeternity/aepp-sdk 10.0.0-beta.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1603 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.js +3 -1
- package/es/account/base.js.map +1 -1
- package/es/account/multiple.js +4 -2
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +52 -38
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +9 -5
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +4 -3
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +4 -4
- package/es/ae/oracle.js.map +1 -1
- package/es/ae/universal.js.map +1 -1
- package/es/chain/index.js +8 -4
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +15 -20
- package/es/chain/node.js.map +1 -1
- package/es/channel/handlers.js.map +1 -1
- package/es/channel/index.js +35 -14
- package/es/channel/index.js.map +1 -1
- package/es/contract/aci/index.js +12 -7
- package/es/contract/aci/index.js.map +1 -1
- package/es/contract/compiler.js +3 -1
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +6 -6
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +6 -2
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +6 -2
- package/es/contract/index.js.map +1 -1
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +4 -2
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +9 -4
- package/es/node.js.map +1 -1
- package/es/tx/builder/helpers.js +20 -33
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +13 -6
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +5 -4
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +101 -12
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +9 -3
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +15 -6
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
- package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +13 -5
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +57 -40
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
- package/es/utils/crypto.js +1 -40
- package/es/utils/crypto.js.map +1 -1
- package/es/utils/keystore.js.map +1 -1
- package/es/utils/swagger.js +3 -1
- package/es/utils/swagger.js.map +1 -1
- package/package.json +11 -13
- package/src/account/base.js +3 -1
- package/src/account/multiple.js +4 -2
- package/src/ae/aens.js +41 -42
- package/src/ae/contract.js +9 -5
- package/src/ae/index.js +4 -3
- package/src/ae/oracle.js +9 -5
- package/src/ae/universal.js +3 -1
- package/src/chain/index.js +8 -4
- package/src/chain/node.js +17 -14
- package/src/channel/handlers.js +10 -3
- package/src/channel/index.js +40 -15
- package/src/contract/aci/index.js +15 -8
- package/src/contract/compiler.js +6 -2
- package/src/contract/ga/helpers.js +5 -3
- package/src/contract/ga/index.js +6 -2
- package/src/contract/index.js +6 -2
- package/src/index.js +2 -0
- package/src/node-pool/index.js +4 -2
- package/src/node.js +7 -4
- package/src/tx/builder/helpers.js +20 -33
- package/src/tx/builder/index.js +49 -13
- package/src/tx/builder/schema.js +37 -14
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +25 -6
- package/src/tx/tx.js +94 -28
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
- package/src/utils/aepp-wallet-communication/helpers.js +4 -2
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +32 -9
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +53 -22
- package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
- package/src/utils/crypto.js +1 -52
- package/src/utils/keystore.js +10 -2
- package/src/utils/swagger.js +1 -1
package/es/utils/swagger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/swagger.js"],"names":["SwaggerClient","fetch","JsonBig","snakizeKeys","pascalizeKeys","mapObject","filterObject","warnedAboutInternalApiUsage","specUrl","spec","internalUrl","disableBigNumbers","disableCaseConversion","responseInterceptor","json","jsonImp","JSON","includes","URL","origin","schemes","external","internal","Promise","all","map","url","response","text","body","parse","Object","assign","combinedApi","values","apis","key","handler","console","warn","reduce","acc","n","opSpecs","paths","flat","operationId","api","opId","slice","toLowerCase","args","opSpec","parameters","requestBody","required","schema","content","name","filter","param","p","length","Error","req","idx","__requestBody","stringified","value","rootKeys","keys","find","properties","filteredValue","stringify"],"mappings":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AI,CAACc,GAAD;AAArB,OAApB,CADa,EAEbd,IAAI,CAACI,QAAQ,CAACO,MAAV,CAAJ,IAAyB,EAFZ,CAAf;AAIA,YAAM;AAAEI,QAAAA,aAAF;AAAiB,WAAGC;AAApB,UAAoC9D,SAAS,CAAC6B,MAAD,EAAS,SAAoB;AAAA,YAAnB,CAAC0B,KAAD,EAAQQ,KAAR,CAAmB;AAC9E,YAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B,OAAO,CAACR,KAAD,EAAQQ,KAAR,CAAP;AAC/B,cAAMC,QAAQ,GAAGtC,MAAM,CAACuC,IAAP,CAAYjB,UAAU,CAACkB,IAAX,CAAgBV,CAAC,IAAIA,CAAC,CAACH,IAAF,KAAWE,KAAhC,EAAuCJ,MAAvC,CAA8CgB,UAA1D,CAAjB;AACA,cAAMC,aAAa,GAAGnE,YAAY,CAChCM,qBAAqB,GAAGwD,KAAH,GAAWjE,WAAW,CAACiE,KAAD,CADX,EAEhC;AAAA,cAAC,CAAChC,GAAD,CAAD;AAAA,iBAAWiC,QAAQ,CAACpD,QAAT,CAAkBmB,GAAlB,CAAX;AAAA,SAFgC,CAAlC;AAIA,eAAO,CAACwB,KAAD,EAAQ7C,OAAO,CAAC2D,SAAR,CAAkBD,aAAlB,CAAR,CAAP;AACD,OARkD,CAAnD;AASA,aAAO,CAAC,MAAMpC,OAAO,CAAC8B,WAAD,EAAc;AAAEb,QAAAA,WAAW,EAAEY;AAAf,OAAd,CAAd,EAA6DrC,IAApE;AACD,KA9BqD,CAArB;AAAA,GAAd,CAArB;AAiCA,SAAOE,MAAM,CAACC,MAAP,CAAcX,QAAd,EAAwB;AAAE0B,IAAAA;AAAF,GAAxB,CAAP;AACD,CAvFD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Generator of Swagger client module\n * @module @aeternity/aepp-sdk/es/utils/swagger\n * @export genSwaggerClient\n */\n\nimport SwaggerClient from 'swagger-client'\nimport fetch from 'cross-fetch'\nimport JsonBig from './json-big'\nimport { snakizeKeys, pascalizeKeys, mapObject, filterObject } from './other'\n\nlet warnedAboutInternalApiUsage = false\n\n/**\n * Generator of Swagger client\n * @function\n * @alias module:@aeternity/aepp-sdk/es/utils/swagger\n * @rtype Object\n * @param {String} specUrl - Swagger specification URL on external node host\n * @param {Object} options\n * @param {String} [options.spec] - Override OpenAPI definition\n * @param {String} [options.internalUrl] - Node internal URL\n * @param {Boolean} [options.disableBigNumbers]\n * @param {Boolean} [options.disableCaseConversion]\n * @param {Function} [options.responseInterceptor]\n * @return {Object} Swagger client\n * @example (await genSwaggerClient('https://mainnet.aeternity.io/api')).getAccountByPubkey('ak_jupBUgZNbcC4krDLR3tAkw1iBZoBbkNeShAq4atBtpFWmz36r')\n */\nexport default async (\n specUrl,\n { spec, internalUrl, disableBigNumbers, disableCaseConversion, responseInterceptor } = {}\n) => {\n spec = spec || await (await fetch(specUrl)).json()\n const jsonImp = disableBigNumbers ? JSON : JsonBig\n\n if (\n [\n 'https://compiler.aepps.com',\n 'https://latest.compiler.aepps.com'\n ].includes(new URL(specUrl).origin) ||\n new URL(specUrl).origin.includes('https://')\n ) {\n spec.schemes = ['https']\n }\n\n const [external, internal] = await Promise.all([specUrl, internalUrl].map((url) => {\n if (!url) return null\n return SwaggerClient({\n url,\n spec,\n responseInterceptor: response => {\n if (!response.text) return response\n const body = jsonImp.parse(response.text)\n Object.assign(response, {\n body: disableCaseConversion ? body : pascalizeKeys(body)\n })\n return (responseInterceptor && responseInterceptor(response)) || response\n }\n })\n }))\n\n const combinedApi = [\n ...Object.values(external.apis),\n mapObject(internal?.apis.internal || {}, ([key, handler]) => [key, (...args) => {\n if (!warnedAboutInternalApiUsage) {\n console.warn(\n 'SDK\\'s wrapper of aeternity node internal API is deprecated, please use external ' +\n 'equivalent (for example, \"sdk.api.protectedDryRunTxs\" instead of \"sdk.api.dryRunTxs\") ' +\n 'or create a wrapper of internal API by yourself (using \"genSwaggerClient\")'\n )\n warnedAboutInternalApiUsage = true\n }\n return handler(...args)\n }])\n ].reduce((acc, n) => ({ ...acc, ...n }))\n\n const opSpecs = Object.values(spec.paths)\n .map(paths => Object.values(paths))\n .flat()\n .reduce((acc, n) => ({ ...acc, [n.operationId]: n }), {})\n\n const api = mapObject(combinedApi, ([opId, handler]) => [\n opId.slice(0, 1).toLowerCase() + opId.slice(1),\n async (...args) => {\n const opSpec = opSpecs[opId]\n const parameters = [\n ...opSpec.parameters,\n ...opSpec.requestBody\n ? [{\n required: opSpec.requestBody.required,\n schema: Object.values(opSpec.requestBody.content)[0].schema,\n name: '__requestBody'\n }]\n : []\n ]\n const required = parameters.filter(param => param.required).map(p => p.name)\n if (args.length < required.length) throw new Error('swagger: Not enough arguments')\n const values = required.reduce(\n (acc, req, idx) => ({ ...acc, [req]: args[idx] }),\n args[required.length] || {}\n )\n const { __requestBody, ...stringified } = mapObject(values, ([param, value]) => {\n if (typeof value !== 'object') return [param, value]\n const rootKeys = Object.keys(parameters.find(p => p.name === param).schema.properties)\n const filteredValue = filterObject(\n disableCaseConversion ? value : snakizeKeys(value),\n ([key]) => rootKeys.includes(key)\n )\n return [param, jsonImp.stringify(filteredValue)]\n })\n return (await handler(stringified, { requestBody: __requestBody })).body\n }\n ])\n\n return Object.assign(external, { api })\n}\n"],"file":"swagger.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/swagger.js"],"names":["SwaggerClient","fetch","JsonBig","snakizeKeys","pascalizeKeys","mapObject","filterObject","warnedAboutInternalApiUsage","specUrl","spec","internalUrl","disableBigNumbers","disableCaseConversion","responseInterceptor","json","jsonImp","JSON","includes","URL","origin","schemes","external","internal","Promise","all","map","url","response","text","size","body","parse","Object","assign","combinedApi","values","apis","key","handler","console","warn","reduce","acc","n","opSpecs","paths","flat","operationId","api","opId","slice","toLowerCase","args","opSpec","parameters","requestBody","required","schema","content","name","filter","param","p","length","Error","req","idx","__requestBody","stringified","value","rootKeys","keys","find","properties","filteredValue","stringify"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA,OAAOA,aAAP,MAA0B,gBAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,SAASC,WAAT,EAAsBC,aAAtB,EAAqCC,SAArC,EAAgDC,YAAhD,QAAoE,SAApE;AAEA,IAAIC,2BAA2B,GAAG,KAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,gBAAe,gBACbC,OADa,EAGV;AAAA,MADH;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,WAAR;AAAqBC,IAAAA,iBAArB;AAAwCC,IAAAA,qBAAxC;AAA+DC,IAAAA;AAA/D,GACG,uEADoF,EACpF;AACHJ,EAAAA,IAAI,GAAGA,IAAI,KAAI,MAAM,CAAC,MAAMR,KAAK,CAACO,OAAD,CAAZ,EAAuBM,IAAvB,EAAV,CAAX;AACA,QAAMC,OAAO,GAAGJ,iBAAiB,GAAGK,IAAH,G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A,iBAAWiC,QAAQ,CAACrD,QAAT,CAAkBoB,GAAlB,CAAX;AAAA,SAFgC,CAAlC;AAIA,eAAO,CAACwB,KAAD,EAAQ9C,OAAO,CAAC4D,SAAR,CAAkBD,aAAlB,CAAR,CAAP;AACD,OARkD,CAAnD;AASA,aAAO,CAAC,MAAMpC,OAAO,CAAC8B,WAAD,EAAc;AAAEb,QAAAA,WAAW,EAAEY;AAAf,OAAd,CAAd,EAA6DrC,IAApE;AACD,KA9BqD,CAArB;AAAA,GAAd,CAArB;AAiCA,SAAOE,MAAM,CAACC,MAAP,CAAcZ,QAAd,EAAwB;AAAE2B,IAAAA;AAAF,GAAxB,CAAP;AACD,CAvFD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Generator of Swagger client module\n * @module @aeternity/aepp-sdk/es/utils/swagger\n * @export genSwaggerClient\n */\n\nimport SwaggerClient from 'swagger-client'\nimport fetch from 'cross-fetch'\nimport JsonBig from './json-big'\nimport { snakizeKeys, pascalizeKeys, mapObject, filterObject } from './other'\n\nlet warnedAboutInternalApiUsage = false\n\n/**\n * Generator of Swagger client\n * @function\n * @alias module:@aeternity/aepp-sdk/es/utils/swagger\n * @rtype Object\n * @param {String} specUrl - Swagger specification URL on external node host\n * @param {Object} options\n * @param {String} [options.spec] - Override OpenAPI definition\n * @param {String} [options.internalUrl] - Node internal URL\n * @param {Boolean} [options.disableBigNumbers]\n * @param {Boolean} [options.disableCaseConversion]\n * @param {Function} [options.responseInterceptor]\n * @return {Object} Swagger client\n * @example (await genSwaggerClient('https://mainnet.aeternity.io/api')).getAccountByPubkey('ak_jupBUgZNbcC4krDLR3tAkw1iBZoBbkNeShAq4atBtpFWmz36r')\n */\nexport default async (\n specUrl,\n { spec, internalUrl, disableBigNumbers, disableCaseConversion, responseInterceptor } = {}\n) => {\n spec = spec || await (await fetch(specUrl)).json()\n const jsonImp = disableBigNumbers ? JSON : JsonBig\n\n if (\n [\n 'https://compiler.aepps.com',\n 'https://latest.compiler.aepps.com'\n ].includes(new URL(specUrl).origin) ||\n new URL(specUrl).origin.includes('https://')\n ) {\n spec.schemes = ['https']\n }\n\n const [external, internal] = await Promise.all([specUrl, internalUrl].map((url) => {\n if (!url) return null\n return SwaggerClient({\n url,\n spec,\n responseInterceptor: response => {\n if (response.text === '' || response.text?.size === 0) return response\n const body = jsonImp.parse(response.text)\n Object.assign(response, {\n body: disableCaseConversion ? body : pascalizeKeys(body)\n })\n return (responseInterceptor && responseInterceptor(response)) || response\n }\n })\n }))\n\n const combinedApi = [\n ...Object.values(external.apis),\n mapObject(internal?.apis.internal || {}, ([key, handler]) => [key, (...args) => {\n if (!warnedAboutInternalApiUsage) {\n console.warn(\n 'SDK\\'s wrapper of aeternity node internal API is deprecated, please use external ' +\n 'equivalent (for example, \"sdk.api.protectedDryRunTxs\" instead of \"sdk.api.dryRunTxs\") ' +\n 'or create a wrapper of internal API by yourself (using \"genSwaggerClient\")'\n )\n warnedAboutInternalApiUsage = true\n }\n return handler(...args)\n }])\n ].reduce((acc, n) => ({ ...acc, ...n }))\n\n const opSpecs = Object.values(spec.paths)\n .map(paths => Object.values(paths))\n .flat()\n .reduce((acc, n) => ({ ...acc, [n.operationId]: n }), {})\n\n const api = mapObject(combinedApi, ([opId, handler]) => [\n opId.slice(0, 1).toLowerCase() + opId.slice(1),\n async (...args) => {\n const opSpec = opSpecs[opId]\n const parameters = [\n ...opSpec.parameters,\n ...opSpec.requestBody\n ? [{\n required: opSpec.requestBody.required,\n schema: Object.values(opSpec.requestBody.content)[0].schema,\n name: '__requestBody'\n }]\n : []\n ]\n const required = parameters.filter(param => param.required).map(p => p.name)\n if (args.length < required.length) throw new Error('swagger: Not enough arguments')\n const values = required.reduce(\n (acc, req, idx) => ({ ...acc, [req]: args[idx] }),\n args[required.length] || {}\n )\n const { __requestBody, ...stringified } = mapObject(values, ([param, value]) => {\n if (typeof value !== 'object') return [param, value]\n const rootKeys = Object.keys(parameters.find(p => p.name === param).schema.properties)\n const filteredValue = filterObject(\n disableCaseConversion ? value : snakizeKeys(value),\n ([key]) => rootKeys.includes(key)\n )\n return [param, jsonImp.stringify(filteredValue)]\n })\n return (await handler(stringified, { requestBody: __requestBody })).body\n }\n ])\n\n return Object.assign(external, { api })\n}\n"],"file":"swagger.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeternity/aepp-sdk",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "SDK for the æternity blockchain",
|
|
5
5
|
"main": "dist/aepp-sdk.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
"docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.js",
|
|
17
17
|
"docs:api": "node apidoc.js",
|
|
18
18
|
"docs:changelog": "cp CHANGELOG.md docs/CHANGELOG.md",
|
|
19
|
-
"lint": "commitlint --from 635f1aa --verbose &&
|
|
19
|
+
"lint": "commitlint --from 635f1aa --verbose && eslint .",
|
|
20
20
|
"test": "nyc --require @babel/register --require ts-node/register mocha './test/unit/' './test/integration/' --recursive --exit --timeout 40s",
|
|
21
21
|
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
|
22
|
-
"test:integration
|
|
23
|
-
"test:integration:contract,chain": "nyc --require @babel/register --require ts-node/register mocha './test/integration/@(contract|contract-aci|chain).js' --timeout 40s",
|
|
24
|
-
"test:integration:else": "nyc --require @babel/register --require ts-node/register mocha './test/integration/!(channel|accounts|contract|chain).js' --timeout 40s",
|
|
22
|
+
"test:integration": "nyc --require @babel/register --require ts-node/register mocha './test/integration/*' --timeout 40s",
|
|
25
23
|
"test:unit": "nyc --require @babel/register --require ts-node/register mocha './test/unit/*'",
|
|
26
24
|
"test:watch": "mocha --recursive --require @babel/register --require ts-node/register --watch --timeout 40s",
|
|
27
25
|
"prepare": "npm run build",
|
|
@@ -36,7 +34,7 @@
|
|
|
36
34
|
"SDK"
|
|
37
35
|
],
|
|
38
36
|
"dependencies": {
|
|
39
|
-
"@aeternity/aepp-calldata": "^1.0.0
|
|
37
|
+
"@aeternity/aepp-calldata": "^1.0.0",
|
|
40
38
|
"@aeternity/bip39": "^0.1.0",
|
|
41
39
|
"@aeternity/json-bigint": "^0.3.1",
|
|
42
40
|
"@babel/runtime-corejs3": "^7.16.3",
|
|
@@ -50,7 +48,6 @@
|
|
|
50
48
|
"buffer": "^6.0.3",
|
|
51
49
|
"cross-fetch": "^3.1.4",
|
|
52
50
|
"crypto-browserify": "^3.12.0",
|
|
53
|
-
"ed2curve": "^0.3.0",
|
|
54
51
|
"events": "^3.3.0",
|
|
55
52
|
"libsodium-wrappers-sumo": "^0.7.9",
|
|
56
53
|
"path-browserify": "^1.0.1",
|
|
@@ -83,11 +80,18 @@
|
|
|
83
80
|
"@types/chai": "^4.2.22",
|
|
84
81
|
"@types/mocha": "^9.0.0",
|
|
85
82
|
"@types/node": "^16.11.9",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
|
84
|
+
"@typescript-eslint/parser": "^5.3.1",
|
|
86
85
|
"babel-loader": "^8.2.3",
|
|
87
86
|
"babel-plugin-ramda": "^2.0.0",
|
|
88
87
|
"chai": "^4.3.4",
|
|
89
88
|
"chai-as-promised": "^7.1.1",
|
|
90
89
|
"codecov": "^3.8.3",
|
|
90
|
+
"eslint": "^7.32.0",
|
|
91
|
+
"eslint-config-standard": "^16.0.3",
|
|
92
|
+
"eslint-plugin-import": "^2.25.3",
|
|
93
|
+
"eslint-plugin-node": "^11.1.0",
|
|
94
|
+
"eslint-plugin-promise": "^5.1.1",
|
|
91
95
|
"jsdoc-to-markdown": "^7.1.0",
|
|
92
96
|
"mocha": "^9.1.3",
|
|
93
97
|
"nyc": "^15.1.0",
|
|
@@ -95,7 +99,6 @@
|
|
|
95
99
|
"source-map": "^0.7.3",
|
|
96
100
|
"standard-version": "^9.3.2",
|
|
97
101
|
"ts-node": "^10.4.0",
|
|
98
|
-
"ts-standard": "^11.0.0",
|
|
99
102
|
"typescript": "^4.5.2",
|
|
100
103
|
"webpack": "^5.64.1",
|
|
101
104
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
@@ -106,11 +109,6 @@
|
|
|
106
109
|
"src",
|
|
107
110
|
"es"
|
|
108
111
|
],
|
|
109
|
-
"ts-standard": {
|
|
110
|
-
"ignore": [
|
|
111
|
-
"examples/**/*.js"
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
112
|
"browserslist": [
|
|
115
113
|
"> 1%",
|
|
116
114
|
"last 2 versions",
|
package/src/account/base.js
CHANGED
|
@@ -85,7 +85,9 @@ async function signMessage (message, opt = { returnHex: false }) {
|
|
|
85
85
|
* Verify message
|
|
86
86
|
* @instance
|
|
87
87
|
* @category async
|
|
88
|
-
* @rtype (
|
|
88
|
+
* @rtype (
|
|
89
|
+
* msg: String, signature: String, publicKey: String
|
|
90
|
+
* ) => signature: Promise[String], throws: Error
|
|
89
91
|
* @param {String} message - Message to verify
|
|
90
92
|
* @param {String} signature - Signature
|
|
91
93
|
* @param {Object} opt - Options
|
package/src/account/multiple.js
CHANGED
|
@@ -41,7 +41,9 @@ import AccountBase, { isAccountBase } from './base'
|
|
|
41
41
|
* @param {String} [options.address] - Address of account to select
|
|
42
42
|
* @return {Object} AccountMultiple instance
|
|
43
43
|
* @example
|
|
44
|
-
* const accounts = await AccountMultiple({
|
|
44
|
+
* const accounts = await AccountMultiple({
|
|
45
|
+
* accounts: [MemoryAccount({ keypair: 'keypair_object' })]
|
|
46
|
+
* })
|
|
45
47
|
* await accounts.addAccount(account, { select: true }) // Add account and make it selected
|
|
46
48
|
* accounts.removeAccount(address) // Remove account
|
|
47
49
|
* accounts.selectAccount(address) // Select account
|
|
@@ -128,7 +130,7 @@ export default AccountBase.compose(AsyncInit, {
|
|
|
128
130
|
},
|
|
129
131
|
/**
|
|
130
132
|
* Resolves an account
|
|
131
|
-
* @param account
|
|
133
|
+
* @param account account address (should exist in sdk instance), MemoryAccount or keypair
|
|
132
134
|
* @returns {AccountBase}
|
|
133
135
|
* @private
|
|
134
136
|
*/
|
package/src/ae/aens.js
CHANGED
|
@@ -28,12 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
import { salt } from '../utils/crypto'
|
|
30
30
|
import {
|
|
31
|
-
commitmentHash,
|
|
32
|
-
ensureNameValid,
|
|
33
|
-
getMinimumNameFee,
|
|
34
|
-
classify,
|
|
35
|
-
isAuctionName,
|
|
36
|
-
validatePointers, encode, produceNameId
|
|
31
|
+
commitmentHash, ensureNameValid, getMinimumNameFee, isAuctionName, encode, produceNameId
|
|
37
32
|
} from '../tx/builder/helpers'
|
|
38
33
|
import Ae from './'
|
|
39
34
|
import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema'
|
|
@@ -46,11 +41,11 @@ import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema'
|
|
|
46
41
|
* @category async
|
|
47
42
|
* @param {String} name Name hash
|
|
48
43
|
* @param {Object} [options={}] options
|
|
49
|
-
* @param {
|
|
50
|
-
* using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
44
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
45
|
+
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
46
|
+
* @param {Number|String|BigNumber} [options.fee] fee
|
|
47
|
+
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
48
|
+
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
54
49
|
* @return {Promise<Object>} Transaction result
|
|
55
50
|
* @example
|
|
56
51
|
* const name = 'test.chain'
|
|
@@ -80,16 +75,19 @@ async function revoke (name, options = {}) {
|
|
|
80
75
|
* @category async
|
|
81
76
|
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
82
77
|
* @param {String} name AENS name
|
|
83
|
-
* @param {
|
|
78
|
+
* @param {Object.<string, string>} pointers Map of pointer keys to corresponding addresses
|
|
84
79
|
* @param {Object} [options={}]
|
|
85
|
-
* @param {Boolean} [options.extendPointers
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
80
|
+
* @param {Boolean} [options.extendPointers] Get the pointers from the node and merge with provided
|
|
81
|
+
* ones. Pointers with the same type will be overwritten
|
|
82
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you
|
|
83
|
+
* pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
84
|
+
* @param {Number|String|BigNumber} [options.fee] fee
|
|
85
|
+
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
86
|
+
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
87
|
+
* @param {Number|String|BigNumber} [options.nameTtl=50000] Name ttl represented in number of
|
|
88
|
+
* blocks (Max value is 50000 blocks)
|
|
89
|
+
* @param {Number|String|BigNumber} [options.clientTtl=84600] a suggestion as to how long any
|
|
90
|
+
* clients should cache this information
|
|
93
91
|
* @return {Promise<Object>}
|
|
94
92
|
* @throws Invalid pointer array error
|
|
95
93
|
* @example
|
|
@@ -99,22 +97,23 @@ async function revoke (name, options = {}) {
|
|
|
99
97
|
*
|
|
100
98
|
* await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
101
99
|
* // or
|
|
102
|
-
* await nameObject.update(
|
|
100
|
+
* await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
103
101
|
*/
|
|
104
|
-
async function update (name, pointers =
|
|
102
|
+
async function update (name, pointers = {}, options = {}) {
|
|
105
103
|
ensureNameValid(name)
|
|
106
104
|
const opt = { ...this.Ae.defaults, ...options }
|
|
107
|
-
|
|
105
|
+
const allPointers = {
|
|
106
|
+
...options.extendPointers && Object.fromEntries(
|
|
107
|
+
(await this.getName(name)).pointers.map(({ key, id }) => [key, id])
|
|
108
|
+
),
|
|
109
|
+
...pointers
|
|
110
|
+
}
|
|
108
111
|
|
|
109
|
-
pointers = [
|
|
110
|
-
...options.extendPointers ? (await this.getName(name)).pointers : [],
|
|
111
|
-
...pointers.map(p => Object.fromEntries([['id', p], ['key', classify(p)]]))
|
|
112
|
-
].reduce((acc, el) => [...acc.filter(p => p.key !== el.key), el], [])
|
|
113
112
|
const nameUpdateTx = await this.nameUpdateTx({
|
|
114
113
|
...opt,
|
|
115
114
|
nameId: produceNameId(name),
|
|
116
115
|
accountId: await this.address(opt),
|
|
117
|
-
pointers
|
|
116
|
+
pointers: Object.entries(allPointers).map(([key, id]) => ({ key, id }))
|
|
118
117
|
})
|
|
119
118
|
|
|
120
119
|
return this.send(nameUpdateTx, opt)
|
|
@@ -129,11 +128,11 @@ async function update (name, pointers = [], options = { extendPointers: false })
|
|
|
129
128
|
* @param {String} name AENS name
|
|
130
129
|
* @param {String} account Recipient account publick key
|
|
131
130
|
* @param {Object} [options={}]
|
|
132
|
-
* @param {
|
|
133
|
-
* using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
134
|
-
* @param {
|
|
135
|
-
* @param {
|
|
136
|
-
* @param {
|
|
131
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
132
|
+
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
133
|
+
* @param {Number|String|BigNumber} [options.fee] fee
|
|
134
|
+
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
135
|
+
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
137
136
|
* @return {Promise<Object>} Transaction result
|
|
138
137
|
* @example
|
|
139
138
|
* const name = 'test.chain'
|
|
@@ -186,7 +185,7 @@ async function query (name, opt = {}) {
|
|
|
186
185
|
|
|
187
186
|
return Object.freeze(Object.assign(o, {
|
|
188
187
|
pointers: o.pointers || [],
|
|
189
|
-
update: async (pointers
|
|
188
|
+
update: async (pointers, options = {}) => {
|
|
190
189
|
return {
|
|
191
190
|
...(await this.aensUpdate(name, pointers, { ...opt, ...options })),
|
|
192
191
|
...(await this.aensQuery(name))
|
|
@@ -203,8 +202,8 @@ async function query (name, opt = {}) {
|
|
|
203
202
|
if (!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL) throw new Error('Ttl must be an number and less then 180000 blocks')
|
|
204
203
|
|
|
205
204
|
return {
|
|
206
|
-
...
|
|
207
|
-
...
|
|
205
|
+
...await this.aensUpdate(name, {}, { ...opt, ...options, nameTtl, extendPointers: true }),
|
|
206
|
+
...await this.aensQuery(name)
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
209
|
}))
|
|
@@ -220,8 +219,8 @@ async function query (name, opt = {}) {
|
|
|
220
219
|
* @param {String} name
|
|
221
220
|
* @param {Number} salt Salt from pre-claim, or 0 if it's a bid
|
|
222
221
|
* @param {Object} [options] options
|
|
223
|
-
* @param {String|Object} [options.onAccount]
|
|
224
|
-
* using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
222
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
223
|
+
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
225
224
|
* @param {Number|String|BigNumber} [options.fee] fee
|
|
226
225
|
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
227
226
|
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
@@ -265,8 +264,8 @@ async function claim (name, salt, options) {
|
|
|
265
264
|
* @alias module:@aeternity/aepp-sdk/es/ae/aens
|
|
266
265
|
* @param {String} name
|
|
267
266
|
* @param {Object} [options={}]
|
|
268
|
-
* @param {String|Object} [options.onAccount]
|
|
269
|
-
* using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
267
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
268
|
+
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
270
269
|
* @param {Number|String|BigNumber} [options.fee] fee
|
|
271
270
|
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
272
271
|
* @param {Number|String|BigNumber} [options.nonce] nonce
|
|
@@ -316,8 +315,8 @@ async function preclaim (name, options = {}) {
|
|
|
316
315
|
* @param {String} name Domain name
|
|
317
316
|
* @param {String|Number} nameFee Name fee (bid fee)
|
|
318
317
|
* @param {Object} [options={}]
|
|
319
|
-
* @param {String|Object} [options.onAccount]
|
|
320
|
-
* using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
318
|
+
* @param {String|Object} [options.onAccount] Make operation on specific account from sdk (you pass
|
|
319
|
+
* publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
|
|
321
320
|
* @param {Number|String|BigNumber} [options.fee] fee
|
|
322
321
|
* @param {Number|String|BigNumber} [options.ttl] ttl
|
|
323
322
|
* @param {Number|String|BigNumber} [options.nonce] nonce
|
package/src/ae/contract.js
CHANGED
|
@@ -95,9 +95,10 @@ async function contractCall (source, contractAddress, name, args, options) {
|
|
|
95
95
|
* @deprecated
|
|
96
96
|
* @param {String} code Compiled contract
|
|
97
97
|
* @param {String} source Contract source code
|
|
98
|
-
* @param {Array} params Arguments of contract constructor(init) function. Can be array of
|
|
98
|
+
* @param {Array} params Arguments of contract constructor(init) function. Can be array of
|
|
99
|
+
* arguments or callData string
|
|
99
100
|
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
|
|
100
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
101
|
+
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
101
102
|
* @return {Promise<Object>} Result object
|
|
102
103
|
* @example
|
|
103
104
|
* const deployed = await client.contractDeploy(bytecode, source, init = [], options)
|
|
@@ -124,7 +125,7 @@ async function contractDeploy (code, source, params, options) {
|
|
|
124
125
|
* @category async
|
|
125
126
|
* @param {String} source Contract sourece code
|
|
126
127
|
* @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
|
|
127
|
-
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
128
|
+
* @param {Object} [options.filesystem={}] Contract external namespaces map*
|
|
128
129
|
* @return {Promise<Object>} Result object
|
|
129
130
|
* @example
|
|
130
131
|
* const compiled = await client.contractCompile(SOURCE_CODE)
|
|
@@ -172,7 +173,8 @@ async function delegateSignatureCommon (ids = [], opt = {}) {
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
/**
|
|
175
|
-
* Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
|
|
176
|
+
* Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
|
|
177
|
+
* a contract.
|
|
176
178
|
* @function
|
|
177
179
|
* @alias module:@aeternity/aepp-sdk/es/ae/contract
|
|
178
180
|
* @category async
|
|
@@ -190,7 +192,9 @@ async function delegateSignatureCommon (ids = [], opt = {}) {
|
|
|
190
192
|
* const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })
|
|
191
193
|
* // Claim, transfer and revoke signature
|
|
192
194
|
* const params = { contractId, name }
|
|
193
|
-
* const aensDelegationSig = await contract.createAensDelegationSignature(
|
|
195
|
+
* const aensDelegationSig = await contract.createAensDelegationSignature(
|
|
196
|
+
* params, name, { onAccount: current }
|
|
197
|
+
* )
|
|
194
198
|
*/
|
|
195
199
|
async function createAensDelegationSignature ({ contractId, name }, opt = {}) {
|
|
196
200
|
return this.delegateSignatureCommon([...name ? [produceNameId(name)] : [], contractId], opt)
|
package/src/ae/index.js
CHANGED
|
@@ -37,7 +37,8 @@ import { AE_AMOUNT_FORMATS } from '../utils/amount-formatter'
|
|
|
37
37
|
* @rtype (tx: String, options: Object) => Promise[String]
|
|
38
38
|
* @param {String} tx - Transaction
|
|
39
39
|
* @param {Object} [options={}] options - Options
|
|
40
|
-
* @param {Object} [options.verify=true]
|
|
40
|
+
* @param {Object} [options.verify=true] - Verify transaction before broadcast, throw error if not
|
|
41
|
+
* valid
|
|
41
42
|
* @return {Object} Transaction
|
|
42
43
|
*/
|
|
43
44
|
async function send (tx, options = {}) {
|
|
@@ -73,7 +74,7 @@ async function spend (amount, recipientIdOrName, options) {
|
|
|
73
74
|
await this.spendTx({
|
|
74
75
|
...opt,
|
|
75
76
|
senderId: await this.address(opt),
|
|
76
|
-
recipientId: await this.resolveName(recipientIdOrName, '
|
|
77
|
+
recipientId: await this.resolveName(recipientIdOrName, 'account_pubkey', opt),
|
|
77
78
|
amount
|
|
78
79
|
}),
|
|
79
80
|
opt
|
|
@@ -96,7 +97,7 @@ async function transferFunds (fraction, recipientIdOrName, options) {
|
|
|
96
97
|
throw new Error(`Fraction should be a number between 0 and 1, got ${fraction}`)
|
|
97
98
|
}
|
|
98
99
|
const opt = { ...this.Ae.defaults, ...options }
|
|
99
|
-
const recipientId = await this.resolveName(recipientIdOrName, '
|
|
100
|
+
const recipientId = await this.resolveName(recipientIdOrName, 'account_pubkey', opt)
|
|
100
101
|
const senderId = await this.address(opt)
|
|
101
102
|
const balance = new BigNumber(await this.balance(senderId))
|
|
102
103
|
const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP)
|
package/src/ae/oracle.js
CHANGED
|
@@ -116,7 +116,11 @@ async function getQueryObject (oracleId, queryId) {
|
|
|
116
116
|
* @param {Object} [options.interval] Poll interval(default: 5000)
|
|
117
117
|
* @return {Promise<Object>} OracleQuery object
|
|
118
118
|
*/
|
|
119
|
-
export async function pollForQueryResponse (
|
|
119
|
+
export async function pollForQueryResponse (
|
|
120
|
+
oracleId,
|
|
121
|
+
queryId,
|
|
122
|
+
{ attempts = 20, interval = 5000 } = {}
|
|
123
|
+
) {
|
|
120
124
|
for (let i = 0; i < attempts; i++) {
|
|
121
125
|
if (i) await pause(interval)
|
|
122
126
|
const { response } = await this.api.getOracleQueryByPubkeyAndQueryId(oracleId, queryId)
|
|
@@ -137,10 +141,10 @@ export async function pollForQueryResponse (oracleId, queryId, { attempts = 20,
|
|
|
137
141
|
* @param {String} queryFormat Format of query
|
|
138
142
|
* @param {String} responseFormat Format of query response
|
|
139
143
|
* @param {Object} [options={}] Options
|
|
140
|
-
* @param {String|Number} [options.queryFee]
|
|
141
|
-
* @param {Object} [options.oracleTtl]
|
|
142
|
-
* @param {Number} [options.abiVersion]
|
|
143
|
-
* @param {Number|String} [options.fee]
|
|
144
|
+
* @param {String|Number} [options.queryFee] Oracle query Fee
|
|
145
|
+
* @param {Object} [options.oracleTtl] OracleTtl object {type: 'delta|block', value: 'number'}
|
|
146
|
+
* @param {Number} [options.abiVersion] Always 0 (do not use virtual machine)
|
|
147
|
+
* @param {Number|String} [options.fee] Transaction fee
|
|
144
148
|
* @param {Number|String} [options.ttl] Transaction time to leave
|
|
145
149
|
* @return {Promise<Object>} Oracle object
|
|
146
150
|
*/
|
package/src/ae/universal.js
CHANGED
|
@@ -42,4 +42,6 @@ import Contract from './contract'
|
|
|
42
42
|
* @param {Object} [options={}] - Initializer object
|
|
43
43
|
* @return {Object} Universal instance
|
|
44
44
|
*/
|
|
45
|
-
export default Ae.compose(
|
|
45
|
+
export default Ae.compose(
|
|
46
|
+
AccountMultiple, Chain, Transaction, Aens, Contract, Oracle, GeneralizeAccount
|
|
47
|
+
)
|
package/src/chain/index.js
CHANGED
|
@@ -113,8 +113,10 @@ const Chain = stampit({
|
|
|
113
113
|
* @rtype (address: String, options?: Object) => balance: Number
|
|
114
114
|
* @param {String} address - The public account address to obtain the balance for
|
|
115
115
|
* @param {Object} [options={}] - Options
|
|
116
|
-
* @param {Number} options.height - The chain height at which to obtain the balance for (default:
|
|
117
|
-
*
|
|
116
|
+
* @param {Number} options.height - The chain height at which to obtain the balance for (default:
|
|
117
|
+
* top of chain)
|
|
118
|
+
* @param {String} options.hash - The block hash on which to obtain the balance for (default: top
|
|
119
|
+
* of chain)
|
|
118
120
|
* @return {Object} The transaction as it was mined
|
|
119
121
|
*/
|
|
120
122
|
|
|
@@ -126,7 +128,8 @@ const Chain = stampit({
|
|
|
126
128
|
* @category async
|
|
127
129
|
* @rtype (hash: String, info = false) => tx: Object
|
|
128
130
|
* @param {String} hash - Transaction hash
|
|
129
|
-
* @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and
|
|
131
|
+
* @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and
|
|
132
|
+
* ContractCall transaction's)
|
|
130
133
|
* @return {Object} Transaction
|
|
131
134
|
*/
|
|
132
135
|
|
|
@@ -239,7 +242,8 @@ const Chain = stampit({
|
|
|
239
242
|
* @param {String} tx - transaction to execute
|
|
240
243
|
* @param {String} accountAddress - address that will be used to execute transaction
|
|
241
244
|
* @param {String|Number} [options.top] - hash of block on which to make dry-run
|
|
242
|
-
* @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result
|
|
245
|
+
* @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result
|
|
246
|
+
* from the call
|
|
243
247
|
* @return {Object} Result
|
|
244
248
|
*/
|
|
245
249
|
|
package/src/chain/node.js
CHANGED
|
@@ -20,7 +20,7 @@ import verifyTransaction from '../tx/validator'
|
|
|
20
20
|
import NodePool from '../node-pool'
|
|
21
21
|
import { pause } from '../utils/other'
|
|
22
22
|
import { isNameValid, produceNameId, decode } from '../tx/builder/helpers'
|
|
23
|
-
import { DRY_RUN_ACCOUNT
|
|
23
|
+
import { DRY_RUN_ACCOUNT } from '../tx/builder/schema'
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* ChainNode module
|
|
@@ -59,7 +59,10 @@ async function sendTransaction (tx, options = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
return { hash: txHash, rawTx: tx }
|
|
61
61
|
} catch (error) {
|
|
62
|
-
throw Object.assign(error, {
|
|
62
|
+
throw Object.assign(error, {
|
|
63
|
+
rawTx: tx,
|
|
64
|
+
verifyTx: () => verifyTransaction(tx, this.selectedNode.instance)
|
|
65
|
+
})
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -217,30 +220,29 @@ async function getName (name) {
|
|
|
217
220
|
/**
|
|
218
221
|
* Resolve AENS name and return name hash
|
|
219
222
|
* @param {String} nameOrId
|
|
220
|
-
* @param {String}
|
|
223
|
+
* @param {String} key in AENS pointers record
|
|
221
224
|
* @param {Object} [options]
|
|
222
225
|
* @param {Boolean} [options.verify] To ensure that name exist and have a corresponding pointer
|
|
223
|
-
*
|
|
226
|
+
* // TODO: avoid that to don't trust to current api gateway
|
|
227
|
+
* @param {Boolean} [options.resolveByNode] Enables pointer resolving using node
|
|
224
228
|
* @return {String} Address or AENS name hash
|
|
225
229
|
*/
|
|
226
|
-
async function resolveName (nameOrId,
|
|
230
|
+
async function resolveName (nameOrId, key, { verify, resolveByNode } = {}) {
|
|
227
231
|
if (!nameOrId || typeof nameOrId !== 'string') {
|
|
228
232
|
throw new Error(`Name or address should be a string: ${nameOrId}`)
|
|
229
233
|
}
|
|
230
|
-
const prefixes = Object.keys(NAME_ID_KEY)
|
|
231
|
-
if (!prefixes.includes(prefix)) {
|
|
232
|
-
throw new Error(`Invalid prefix ${prefix}, should be one of [${prefixes}]`)
|
|
233
|
-
}
|
|
234
234
|
try {
|
|
235
|
-
decode(nameOrId
|
|
235
|
+
decode(nameOrId)
|
|
236
236
|
return nameOrId
|
|
237
237
|
} catch (error) {}
|
|
238
238
|
if (isNameValid(nameOrId)) {
|
|
239
239
|
if (verify || resolveByNode) {
|
|
240
|
-
const name = await this.
|
|
240
|
+
const name = await this.api.getNameEntryByName(nameOrId).catch(_ => null)
|
|
241
241
|
if (!name) throw new Error(`Name not found: ${nameOrId}`)
|
|
242
|
-
const pointer = name.pointers.find(
|
|
243
|
-
if (!pointer)
|
|
242
|
+
const pointer = name.pointers.find(pointer => pointer.key === key)
|
|
243
|
+
if (!pointer) {
|
|
244
|
+
throw new Error(`Name ${nameOrId} don't have pointers for ${key}`)
|
|
245
|
+
}
|
|
244
246
|
if (resolveByNode) return pointer.id
|
|
245
247
|
}
|
|
246
248
|
return produceNameId(nameOrId)
|
|
@@ -252,7 +254,8 @@ async function resolveName (nameOrId, prefix, { verify, resolveByNode } = {}) {
|
|
|
252
254
|
* ChainNode Stamp
|
|
253
255
|
*
|
|
254
256
|
* This is implementation of {@link module:@aeternity/aepp-sdk/es/chain--Chain}
|
|
255
|
-
* composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and
|
|
257
|
+
* composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and
|
|
258
|
+
* {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
|
|
256
259
|
* @function
|
|
257
260
|
* @alias module:@aeternity/aepp-sdk/es/chain/node
|
|
258
261
|
* @rtype Stamp
|
package/src/channel/handlers.js
CHANGED
|
@@ -102,7 +102,9 @@ export async function awaitingChannelCreateTx (channel, message, state) {
|
|
|
102
102
|
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
|
|
103
103
|
return { handler: awaitingOnChainTx }
|
|
104
104
|
}
|
|
105
|
-
const signedTx = await appendSignature(
|
|
105
|
+
const signedTx = await appendSignature(
|
|
106
|
+
message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx)
|
|
107
|
+
)
|
|
106
108
|
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { signed_tx: signedTx } })
|
|
107
109
|
return { handler: awaitingOnChainTx }
|
|
108
110
|
}
|
|
@@ -574,11 +576,16 @@ export function awaitingNewContractCompletion (channel, message, state) {
|
|
|
574
576
|
export async function awaitingCallContractUpdateTx (channel, message, state) {
|
|
575
577
|
if (message.method === 'channels.sign.update') {
|
|
576
578
|
if (message.params.data.tx) {
|
|
577
|
-
const signedTx = await state.sign(
|
|
579
|
+
const signedTx = await state.sign(
|
|
580
|
+
message.params.data.tx, { updates: message.params.data.updates }
|
|
581
|
+
)
|
|
578
582
|
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
|
|
579
583
|
return { handler: awaitingCallContractCompletion, state }
|
|
580
584
|
}
|
|
581
|
-
const signedTx = await appendSignature(
|
|
585
|
+
const signedTx = await appendSignature(
|
|
586
|
+
message.params.data.signed_tx,
|
|
587
|
+
tx => state.sign(tx, { updates: message.params.data.updates })
|
|
588
|
+
)
|
|
582
589
|
if (typeof signedTx === 'string') {
|
|
583
590
|
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
|
|
584
591
|
return { handler: awaitingCallContractCompletion, state }
|