@aeternity/aepp-sdk 9.0.1 → 10.0.0-beta.1
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/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
- 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 +30 -122
- package/es/account/base.js.map +1 -1
- package/es/account/memory.js +17 -19
- package/es/account/memory.js.map +1 -1
- package/es/account/multiple.js +73 -164
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +164 -599
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +82 -759
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +78 -315
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +130 -498
- package/es/ae/oracle.js.map +1 -1
- package/es/chain/index.js +1 -1
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +288 -1008
- package/es/chain/node.js.map +1 -1
- package/es/channel/handlers.js +597 -1086
- package/es/channel/handlers.js.map +1 -1
- package/es/channel/index.js +203 -451
- package/es/channel/index.js.map +1 -1
- package/es/channel/internal.js +129 -301
- package/es/channel/internal.js.map +1 -1
- package/es/contract/aci/index.js +319 -480
- package/es/contract/aci/index.js.map +1 -1
- package/es/contract/aci/transformation.js +35 -711
- package/es/contract/aci/transformation.js.map +1 -1
- package/es/contract/compiler.js +129 -203
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +16 -114
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +101 -242
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +1 -1
- package/es/contract/index.js.map +1 -1
- package/es/index.js +1 -2
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +54 -73
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +56 -157
- package/es/node.js.map +1 -1
- package/es/other.d.ts +1 -1
- package/es/tx/builder/helpers.js +38 -75
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +196 -294
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +577 -459
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +1 -1
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +105 -132
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +808 -1628
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +132 -268
- package/es/tx/validator.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
- package/es/utils/aepp-wallet-communication/helpers.js +60 -105
- package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +353 -600
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/schema.js +43 -39
- package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
- package/es/utils/amount-formatter.js +41 -61
- package/es/utils/amount-formatter.js.map +1 -1
- package/es/utils/async-init.js +28 -64
- package/es/utils/async-init.js.map +1 -1
- package/es/utils/bignumber.js +3 -11
- package/es/utils/bignumber.js.map +1 -1
- package/es/utils/bytes.js +5 -9
- package/es/utils/bytes.js.map +1 -1
- package/es/utils/crypto.js +47 -62
- package/es/utils/crypto.js.map +1 -1
- package/es/utils/hd-wallet.js +45 -81
- package/es/utils/hd-wallet.js.map +1 -1
- package/es/utils/json-big.js +16 -49
- package/es/utils/json-big.js.map +1 -1
- package/es/utils/keystore.js +81 -246
- package/es/utils/keystore.js.map +1 -1
- package/es/utils/mptree.js +88 -134
- package/es/utils/mptree.js.map +1 -1
- package/es/utils/other.js +10 -60
- package/es/utils/other.js.map +1 -1
- package/es/utils/semver-satisfies.js +9 -28
- package/es/utils/semver-satisfies.js.map +1 -1
- package/es/utils/string.js +4 -13
- package/es/utils/string.js.map +1 -1
- package/es/utils/swagger.js +85 -224
- package/es/utils/swagger.js.map +1 -1
- package/package.json +44 -40
- package/src/account/multiple.js +18 -19
- package/src/ae/aens.js +25 -21
- package/src/ae/contract.js +32 -163
- package/src/ae/index.js +3 -3
- package/src/ae/oracle.js +18 -14
- package/src/chain/node.js +2 -4
- package/src/channel/handlers.js +0 -1
- package/src/channel/index.js +4 -5
- package/src/contract/aci/index.js +221 -102
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +45 -4
- package/src/contract/ga/helpers.js +1 -8
- package/src/contract/ga/index.js +13 -11
- package/src/index.js +0 -2
- package/src/node-pool/index.js +21 -12
- package/src/node.js +22 -26
- package/src/tx/builder/index.js +2 -1
- package/src/tx/builder/schema.js +2 -1
- package/src/tx/tx.js +147 -143
- package/src/tx/validator.js +9 -7
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +3 -3
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +14 -7
- package/src/contract/aci/helpers.js +0 -140
|
@@ -1,120 +1,22 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
4
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
5
1
|
import BigNumber from 'bignumber.js';
|
|
6
2
|
import { MAX_AUTH_FUN_GAS } from '../../tx/builder/schema';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
case 0:
|
|
18
|
-
if (!(_typeof(authData) !== 'object')) {
|
|
19
|
-
_context2.next = 2;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
throw new Error('AuthData must be an object');
|
|
24
|
-
|
|
25
|
-
case 2:
|
|
26
|
-
if (!(authData.gas && BigNumber(authData.gas).gt(MAX_AUTH_FUN_GAS))) {
|
|
27
|
-
_context2.next = 4;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
throw new Error(_concatInstanceProperty(_context = "the maximum gas value for ga authFun is ".concat(MAX_AUTH_FUN_GAS, ", got ")).call(_context, authData.gas));
|
|
32
|
-
|
|
33
|
-
case 4:
|
|
34
|
-
gas = authData.gas || MAX_AUTH_FUN_GAS;
|
|
35
|
-
|
|
36
|
-
if (!authData.callData) {
|
|
37
|
-
_context2.next = 11;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!(authData.callData.split('_')[0] !== 'cb')) {
|
|
42
|
-
_context2.next = 8;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
throw new Error('Auth data must be a string with "cb" prefix.');
|
|
47
|
-
|
|
48
|
-
case 8:
|
|
49
|
-
return _context2.abrupt("return", {
|
|
50
|
-
authCallData: authData.callData,
|
|
51
|
-
gas: gas
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
case 11:
|
|
55
|
-
if (!(!authData.source || !authData.args)) {
|
|
56
|
-
_context2.next = 13;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
throw new Error('Auth data must contain source code and arguments.');
|
|
61
|
-
|
|
62
|
-
case 13:
|
|
63
|
-
_context2.next = 15;
|
|
64
|
-
return ins.contractEncodeCall(authData.source, authFnName, authData.args);
|
|
65
|
-
|
|
66
|
-
case 15:
|
|
67
|
-
_context2.t0 = _context2.sent;
|
|
68
|
-
_context2.t1 = gas;
|
|
69
|
-
return _context2.abrupt("return", {
|
|
70
|
-
authCallData: _context2.t0,
|
|
71
|
-
gas: _context2.t1
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
case 18:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context2.stop();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, _callee);
|
|
80
|
-
}));
|
|
81
|
-
|
|
82
|
-
return function (_x, _x2) {
|
|
83
|
-
return _ref.apply(this, arguments);
|
|
3
|
+
export const prepareGaParams = ins => async (authData, authFnName) => {
|
|
4
|
+
if (typeof authData !== 'object') throw new Error('AuthData must be an object');
|
|
5
|
+
if (authData.gas && BigNumber(authData.gas).gt(MAX_AUTH_FUN_GAS)) throw new Error(`the maximum gas value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${authData.gas}`);
|
|
6
|
+
const gas = authData.gas || MAX_AUTH_FUN_GAS;
|
|
7
|
+
|
|
8
|
+
if (authData.callData) {
|
|
9
|
+
if (authData.callData.split('_')[0] !== 'cb') throw new Error('Auth data must be a string with "cb" prefix.');
|
|
10
|
+
return {
|
|
11
|
+
authCallData: authData.callData,
|
|
12
|
+
gas
|
|
84
13
|
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var _yield$ins$contractCo, bytecode;
|
|
91
|
-
|
|
92
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
93
|
-
while (1) {
|
|
94
|
-
switch (_context3.prev = _context3.next) {
|
|
95
|
-
case 0:
|
|
96
|
-
_context3.next = 2;
|
|
97
|
-
return ins.contractCompile(source);
|
|
98
|
-
|
|
99
|
-
case 2:
|
|
100
|
-
_yield$ins$contractCo = _context3.sent;
|
|
101
|
-
bytecode = _yield$ins$contractCo.bytecode;
|
|
102
|
-
return _context3.abrupt("return", {
|
|
103
|
-
bytecode: bytecode,
|
|
104
|
-
authFun: hash(fnName)
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
case 5:
|
|
108
|
-
case "end":
|
|
109
|
-
return _context3.stop();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, _callee2);
|
|
113
|
-
}));
|
|
114
|
-
|
|
115
|
-
return function (_x3, _x4) {
|
|
116
|
-
return _ref2.apply(this, arguments);
|
|
14
|
+
} else {
|
|
15
|
+
if (!authData.source || !authData.args) throw new Error('Auth data must contain source code and arguments.');
|
|
16
|
+
return {
|
|
17
|
+
authCallData: await ins.contractEncodeCallDataAPI(authData.source, authFnName, authData.args),
|
|
18
|
+
gas
|
|
117
19
|
};
|
|
118
|
-
}
|
|
20
|
+
}
|
|
119
21
|
};
|
|
120
22
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contract/ga/helpers.js"],"names":["BigNumber","MAX_AUTH_FUN_GAS","
|
|
1
|
+
{"version":3,"sources":["../../../src/contract/ga/helpers.js"],"names":["BigNumber","MAX_AUTH_FUN_GAS","prepareGaParams","ins","authData","authFnName","Error","gas","gt","callData","split","authCallData","source","args","contractEncodeCallDataAPI"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,cAAtB;AACA,SAASC,gBAAT,QAAiC,yBAAjC;AAEA,OAAO,MAAMC,eAAe,GAAIC,GAAD,IAAS,OAAOC,QAAP,EAAiBC,UAAjB,KAAgC;AACtE,MAAI,OAAOD,QAAP,KAAoB,QAAxB,EAAkC,MAAM,IAAIE,KAAJ,CAAU,4BAAV,CAAN;AAClC,MAAIF,QAAQ,CAACG,GAAT,IAAgBP,SAAS,CAACI,QAAQ,CAACG,GAAV,CAAT,CAAwBC,EAAxB,CAA2BP,gBAA3B,CAApB,EAAkE,MAAM,IAAIK,KAAJ,CAAW,2CAA0CL,gBAAiB,SAAQG,QAAQ,CAACG,GAAI,EAA3F,CAAN;AAClE,QAAMA,GAAG,GAAGH,QAAQ,CAACG,GAAT,IAAgBN,gBAA5B;;AACA,MAAIG,QAAQ,CAACK,QAAb,EAAuB;AACrB,QAAIL,QAAQ,CAACK,QAAT,CAAkBC,KAAlB,CAAwB,GAAxB,EAA6B,CAA7B,MAAoC,IAAxC,EAA8C,MAAM,IAAIJ,KAAJ,CAAU,8CAAV,CAAN;AAC9C,WAAO;AAAEK,MAAAA,YAAY,EAAEP,QAAQ,CAACK,QAAzB;AAAmCF,MAAAA;AAAnC,KAAP;AACD,GAHD,MAGO;AACL,QAAI,CAACH,QAAQ,CAACQ,MAAV,IAAoB,CAACR,QAAQ,CAACS,IAAlC,EAAwC,MAAM,IAAIP,KAAJ,CAAU,mDAAV,CAAN;AACxC,WAAO;AAAEK,MAAAA,YAAY,EAAE,MAAMR,GAAG,CAACW,yBAAJ,CAA8BV,QAAQ,CAACQ,MAAvC,EAA+CP,UAA/C,EAA2DD,QAAQ,CAACS,IAApE,CAAtB;AAAiGN,MAAAA;AAAjG,KAAP;AACD;AACF,CAXM","sourcesContent":["import BigNumber from 'bignumber.js'\nimport { MAX_AUTH_FUN_GAS } from '../../tx/builder/schema'\n\nexport const prepareGaParams = (ins) => async (authData, authFnName) => {\n if (typeof authData !== 'object') throw new Error('AuthData must be an object')\n if (authData.gas && BigNumber(authData.gas).gt(MAX_AUTH_FUN_GAS)) throw new Error(`the maximum gas value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${authData.gas}`)\n const gas = authData.gas || MAX_AUTH_FUN_GAS\n if (authData.callData) {\n if (authData.callData.split('_')[0] !== 'cb') throw new Error('Auth data must be a string with \"cb\" prefix.')\n return { authCallData: authData.callData, gas }\n } else {\n if (!authData.source || !authData.args) throw new Error('Auth data must contain source code and arguments.')\n return { authCallData: await ins.contractEncodeCallDataAPI(authData.source, authFnName, authData.args), gas }\n }\n}\n"],"file":"helpers.js"}
|
package/es/contract/ga/index.js
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/*
|
|
2
|
+
* ISC License (ISC)
|
|
3
|
+
* Copyright (c) 2018 aeternity developers
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
* copyright notice and this permission notice appear in all copies.
|
|
8
|
+
*
|
|
9
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
*/
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
17
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
18
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
18
|
+
/**
|
|
19
|
+
* Generalize Account module - routines to use generalize account
|
|
20
|
+
*
|
|
21
|
+
* @module @aeternity/aepp-sdk/es/contract/ga
|
|
22
|
+
* @export GeneralizeAccount
|
|
23
|
+
* @example import { GeneralizeAccount } from '@aeternity/aepp-sdk'
|
|
24
|
+
*/
|
|
19
25
|
import { ContractAPI } from '../../ae/contract';
|
|
20
26
|
import { TX_TYPE } from '../../tx/builder/schema';
|
|
21
27
|
import { buildTx, unpackTx } from '../../tx/builder';
|
|
22
|
-
import {
|
|
28
|
+
import { prepareGaParams } from './helpers';
|
|
29
|
+
import { hash } from '../../utils/crypto';
|
|
23
30
|
/**
|
|
24
31
|
* GeneralizeAccount Stamp
|
|
25
32
|
*
|
|
@@ -40,11 +47,11 @@ import { getContractAuthFan, prepareGaParams } from './helpers';
|
|
|
40
47
|
* await client.spend(10000, receiverPub, { authData: { source: authContract, args: [...authContractArgs] } }) // sdk will prepare callData itself
|
|
41
48
|
*/
|
|
42
49
|
|
|
43
|
-
export
|
|
50
|
+
export const GeneralizeAccount = ContractAPI.compose({
|
|
44
51
|
methods: {
|
|
45
|
-
createGeneralizeAccount
|
|
46
|
-
createMetaTx
|
|
47
|
-
isGA
|
|
52
|
+
createGeneralizeAccount,
|
|
53
|
+
createMetaTx,
|
|
54
|
+
isGA
|
|
48
55
|
}
|
|
49
56
|
});
|
|
50
57
|
export default GeneralizeAccount;
|
|
@@ -56,8 +63,11 @@ export default GeneralizeAccount;
|
|
|
56
63
|
* @return {Boolean}
|
|
57
64
|
*/
|
|
58
65
|
|
|
59
|
-
function isGA(
|
|
60
|
-
|
|
66
|
+
async function isGA(address) {
|
|
67
|
+
const {
|
|
68
|
+
contractId
|
|
69
|
+
} = await this.getAccount(address);
|
|
70
|
+
return !!contractId;
|
|
61
71
|
}
|
|
62
72
|
/**
|
|
63
73
|
* Convert current account to GA account
|
|
@@ -71,132 +81,39 @@ function isGA(_x) {
|
|
|
71
81
|
*/
|
|
72
82
|
|
|
73
83
|
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return _createGeneralizeAccount.apply(this, arguments);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _createGeneralizeAccount() {
|
|
105
|
-
_createGeneralizeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(authFnName, source) {
|
|
106
|
-
var args,
|
|
107
|
-
options,
|
|
108
|
-
opt,
|
|
109
|
-
ownerId,
|
|
110
|
-
_yield$getContractAut,
|
|
111
|
-
authFun,
|
|
112
|
-
bytecode,
|
|
113
|
-
callData,
|
|
114
|
-
_yield$this$gaAttachT,
|
|
115
|
-
tx,
|
|
116
|
-
contractId,
|
|
117
|
-
_yield$this$send,
|
|
118
|
-
hash,
|
|
119
|
-
rawTx,
|
|
120
|
-
_args2 = arguments;
|
|
121
|
-
|
|
122
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
123
|
-
while (1) {
|
|
124
|
-
switch (_context2.prev = _context2.next) {
|
|
125
|
-
case 0:
|
|
126
|
-
args = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
|
|
127
|
-
options = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
|
|
128
|
-
opt = _merge(this.Ae.defaults, options);
|
|
129
|
-
_context2.next = 5;
|
|
130
|
-
return this.address(opt);
|
|
131
|
-
|
|
132
|
-
case 5:
|
|
133
|
-
ownerId = _context2.sent;
|
|
134
|
-
_context2.next = 8;
|
|
135
|
-
return this.isGA(ownerId);
|
|
136
|
-
|
|
137
|
-
case 8:
|
|
138
|
-
if (!_context2.sent) {
|
|
139
|
-
_context2.next = 10;
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
throw new Error("Account ".concat(ownerId, " is already GA"));
|
|
144
|
-
|
|
145
|
-
case 10:
|
|
146
|
-
_context2.next = 12;
|
|
147
|
-
return getContractAuthFan(this)(source, authFnName);
|
|
148
|
-
|
|
149
|
-
case 12:
|
|
150
|
-
_yield$getContractAut = _context2.sent;
|
|
151
|
-
authFun = _yield$getContractAut.authFun;
|
|
152
|
-
bytecode = _yield$getContractAut.bytecode;
|
|
153
|
-
_context2.next = 17;
|
|
154
|
-
return this.contractEncodeCall(source, 'init', args);
|
|
155
|
-
|
|
156
|
-
case 17:
|
|
157
|
-
callData = _context2.sent;
|
|
158
|
-
_context2.next = 20;
|
|
159
|
-
return this.gaAttachTx(_merge(opt, {
|
|
160
|
-
ownerId: ownerId,
|
|
161
|
-
code: bytecode,
|
|
162
|
-
callData: callData,
|
|
163
|
-
authFun: authFun
|
|
164
|
-
}));
|
|
165
|
-
|
|
166
|
-
case 20:
|
|
167
|
-
_yield$this$gaAttachT = _context2.sent;
|
|
168
|
-
tx = _yield$this$gaAttachT.tx;
|
|
169
|
-
contractId = _yield$this$gaAttachT.contractId;
|
|
170
|
-
_context2.next = 25;
|
|
171
|
-
return this.send(tx, opt);
|
|
172
|
-
|
|
173
|
-
case 25:
|
|
174
|
-
_yield$this$send = _context2.sent;
|
|
175
|
-
hash = _yield$this$send.hash;
|
|
176
|
-
rawTx = _yield$this$send.rawTx;
|
|
177
|
-
return _context2.abrupt("return", _Object$freeze({
|
|
178
|
-
owner: ownerId,
|
|
179
|
-
transaction: hash,
|
|
180
|
-
rawTx: rawTx,
|
|
181
|
-
gaContractId: contractId
|
|
182
|
-
}));
|
|
183
|
-
|
|
184
|
-
case 29:
|
|
185
|
-
case "end":
|
|
186
|
-
return _context2.stop();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}, _callee2, this);
|
|
190
|
-
}));
|
|
191
|
-
return _createGeneralizeAccount.apply(this, arguments);
|
|
84
|
+
async function createGeneralizeAccount(authFnName, source) {
|
|
85
|
+
let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
86
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
87
|
+
const opt = { ...this.Ae.defaults,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
const ownerId = await this.address(opt);
|
|
91
|
+
if (await this.isGA(ownerId)) throw new Error(`Account ${ownerId} is already GA`);
|
|
92
|
+
const {
|
|
93
|
+
tx,
|
|
94
|
+
contractId
|
|
95
|
+
} = await this.gaAttachTx({ ...opt,
|
|
96
|
+
ownerId,
|
|
97
|
+
code: (await this.contractCompile(source)).bytecode,
|
|
98
|
+
callData: await this.contractEncodeCallDataAPI(source, 'init', args),
|
|
99
|
+
authFun: hash(authFnName)
|
|
100
|
+
});
|
|
101
|
+
const {
|
|
102
|
+
hash: transaction,
|
|
103
|
+
rawTx
|
|
104
|
+
} = await this.send(tx, opt);
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
owner: ownerId,
|
|
107
|
+
transaction,
|
|
108
|
+
rawTx,
|
|
109
|
+
gaContractId: contractId
|
|
110
|
+
});
|
|
192
111
|
}
|
|
193
112
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}, TX_TYPE.signed);
|
|
199
|
-
};
|
|
113
|
+
const wrapInEmptySignedTx = tx => buildTx({
|
|
114
|
+
encodedTx: tx,
|
|
115
|
+
signatures: []
|
|
116
|
+
}, TX_TYPE.signed);
|
|
200
117
|
/**
|
|
201
118
|
* Create a metaTx transaction
|
|
202
119
|
* @alias module:@aeternity/aepp-sdk/es/contract/ga
|
|
@@ -209,99 +126,41 @@ var wrapInEmptySignedTx = function wrapInEmptySignedTx(tx) {
|
|
|
209
126
|
*/
|
|
210
127
|
|
|
211
128
|
|
|
212
|
-
function createMetaTx(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return prepareGaParams(this)(authData, authFnName);
|
|
249
|
-
|
|
250
|
-
case 5:
|
|
251
|
-
_yield$prepareGaParam = _context3.sent;
|
|
252
|
-
authCallData = _yield$prepareGaParam.authCallData;
|
|
253
|
-
gas = _yield$prepareGaParam.gas;
|
|
254
|
-
opt = _merge(this.Ae.defaults, options);
|
|
255
|
-
_context3.next = 11;
|
|
256
|
-
return this.getVmVersion(TX_TYPE.contractCall);
|
|
257
|
-
|
|
258
|
-
case 11:
|
|
259
|
-
_yield$this$getVmVers = _context3.sent;
|
|
260
|
-
abiVersion = _yield$this$getVmVers.abiVersion;
|
|
261
|
-
wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction));
|
|
262
|
-
_context3.t0 = _objectSpread;
|
|
263
|
-
_context3.t1 = _objectSpread({}, opt);
|
|
264
|
-
_context3.t2 = {};
|
|
265
|
-
_context3.t3 = _objectSpread(_objectSpread({}, wrappedTx), {}, {
|
|
266
|
-
tx: wrappedTx.txObject
|
|
267
|
-
});
|
|
268
|
-
_context3.next = 20;
|
|
269
|
-
return this.address(opt);
|
|
270
|
-
|
|
271
|
-
case 20:
|
|
272
|
-
_context3.t4 = _context3.sent;
|
|
273
|
-
_context3.t5 = abiVersion;
|
|
274
|
-
_context3.t6 = authCallData;
|
|
275
|
-
_context3.t7 = gas;
|
|
276
|
-
_context3.t8 = {
|
|
277
|
-
tx: _context3.t3,
|
|
278
|
-
gaId: _context3.t4,
|
|
279
|
-
abiVersion: _context3.t5,
|
|
280
|
-
authData: _context3.t6,
|
|
281
|
-
gas: _context3.t7,
|
|
282
|
-
vsn: 2
|
|
283
|
-
};
|
|
284
|
-
params = (0, _context3.t0)(_context3.t1, _context3.t2, _context3.t8);
|
|
285
|
-
_context3.next = 28;
|
|
286
|
-
return this.prepareTxParams(TX_TYPE.gaMeta, params);
|
|
287
|
-
|
|
288
|
-
case 28:
|
|
289
|
-
_yield$this$prepareTx = _context3.sent;
|
|
290
|
-
fee = _yield$this$prepareTx.fee;
|
|
291
|
-
_buildTx = buildTx(_objectSpread(_objectSpread({}, params), {}, {
|
|
292
|
-
fee: "".concat(fee)
|
|
293
|
-
}), TX_TYPE.gaMeta, {
|
|
294
|
-
vsn: 2
|
|
295
|
-
}), metaTxRlp = _buildTx.rlpEncoded;
|
|
296
|
-
return _context3.abrupt("return", wrapInEmptySignedTx(metaTxRlp).tx);
|
|
297
|
-
|
|
298
|
-
case 32:
|
|
299
|
-
case "end":
|
|
300
|
-
return _context3.stop();
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}, _callee3, this);
|
|
304
|
-
}));
|
|
305
|
-
return _createMetaTx.apply(this, arguments);
|
|
129
|
+
async function createMetaTx(rawTransaction, authData, authFnName) {
|
|
130
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
131
|
+
if (!authData) throw new Error('authData is required'); // Check if authData is callData or if it's an object prepare a callData from source and args
|
|
132
|
+
|
|
133
|
+
const {
|
|
134
|
+
authCallData,
|
|
135
|
+
gas
|
|
136
|
+
} = await prepareGaParams(this)(authData, authFnName);
|
|
137
|
+
const opt = { ...this.Ae.defaults,
|
|
138
|
+
...options
|
|
139
|
+
};
|
|
140
|
+
const {
|
|
141
|
+
abiVersion
|
|
142
|
+
} = await this.getVmVersion(TX_TYPE.contractCall);
|
|
143
|
+
const wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction));
|
|
144
|
+
const params = { ...opt,
|
|
145
|
+
tx: { ...wrappedTx,
|
|
146
|
+
tx: wrappedTx.txObject
|
|
147
|
+
},
|
|
148
|
+
gaId: await this.address(opt),
|
|
149
|
+
abiVersion: abiVersion,
|
|
150
|
+
authData: authCallData,
|
|
151
|
+
gas,
|
|
152
|
+
vsn: 2
|
|
153
|
+
};
|
|
154
|
+
const {
|
|
155
|
+
fee
|
|
156
|
+
} = await this.prepareTxParams(TX_TYPE.gaMeta, params);
|
|
157
|
+
const {
|
|
158
|
+
rlpEncoded: metaTxRlp
|
|
159
|
+
} = buildTx({ ...params,
|
|
160
|
+
fee: `${fee}`
|
|
161
|
+
}, TX_TYPE.gaMeta, {
|
|
162
|
+
vsn: 2
|
|
163
|
+
});
|
|
164
|
+
return wrapInEmptySignedTx(metaTxRlp).tx;
|
|
306
165
|
}
|
|
307
166
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contract/ga/index.js"],"names":["ContractAPI","TX_TYPE","buildTx","unpackTx","
|
|
1
|
+
{"version":3,"sources":["../../../src/contract/ga/index.js"],"names":["ContractAPI","TX_TYPE","buildTx","unpackTx","prepareGaParams","hash","GeneralizeAccount","compose","methods","createGeneralizeAccount","createMetaTx","isGA","address","contractId","getAccount","authFnName","source","args","options","opt","Ae","defaults","ownerId","Error","tx","gaAttachTx","code","contractCompile","bytecode","callData","contractEncodeCallDataAPI","authFun","transaction","rawTx","send","Object","freeze","owner","gaContractId","wrapInEmptySignedTx","encodedTx","signatures","signed","rawTransaction","authData","authCallData","gas","abiVersion","getVmVersion","contractCall","wrappedTx","params","txObject","gaId","vsn","fee","prepareTxParams","gaMeta","rlpEncoded","metaTxRlp"],"mappings":"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","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 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 * Generalize Account module - routines to use generalize account\n *\n * @module @aeternity/aepp-sdk/es/contract/ga\n * @export GeneralizeAccount\n * @example import { GeneralizeAccount } from '@aeternity/aepp-sdk'\n */\nimport { ContractAPI } from '../../ae/contract'\nimport { TX_TYPE } from '../../tx/builder/schema'\nimport { buildTx, unpackTx } from '../../tx/builder'\nimport { prepareGaParams } from './helpers'\nimport { hash } from '../../utils/crypto'\n\n/**\n * GeneralizeAccount Stamp\n *\n * Provide Generalize Account implementation\n * {@link module:@aeternity/aepp-sdk/es/contract/ga} clients.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} GeneralizeAccount instance\n * @example\n * const authContract = ``\n * await client.createGeneralizeAccount(authFnName, authContract, [...authFnArguments]\n * // Make spend using GA\n * const callData = 'cb_...' // encoded call data for auth contract\n * await client.spend(10000, receiverPub, { authData: { callData } })\n * // or\n * await client.spend(10000, receiverPub, { authData: { source: authContract, args: [...authContractArgs] } }) // sdk will prepare callData itself\n */\nexport const GeneralizeAccount = ContractAPI.compose({\n methods: {\n createGeneralizeAccount,\n createMetaTx,\n isGA\n }\n})\nexport default GeneralizeAccount\n\n/**\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * Check if account is GA account\n * @param {String} address - Account address\n * @return {Boolean}\n */\nasync function isGA (address) {\n const { contractId } = await this.getAccount(address)\n return !!contractId\n}\n\n/**\n * Convert current account to GA account\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * @param {String} authFnName - Authorization function name\n * @param {String} source - Auth contract source code\n * @param {Array} [args] - init arguments\n * @param {Object} [options] - Options\n * @return {Promise<Readonly<{result: *, owner: *, createdAt: Date, address, rawTx: *, transaction: *}>>}\n */\nasync function createGeneralizeAccount (authFnName, source, args = [], options = {}) {\n const opt = { ...this.Ae.defaults, ...options }\n const ownerId = await this.address(opt)\n\n if (await this.isGA(ownerId)) throw new Error(`Account ${ownerId} is already GA`)\n\n const { tx, contractId } = await this.gaAttachTx({\n ...opt,\n ownerId,\n code: (await this.contractCompile(source)).bytecode,\n callData: await this.contractEncodeCallDataAPI(source, 'init', args),\n authFun: hash(authFnName)\n })\n\n const { hash: transaction, rawTx } = await this.send(tx, opt)\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId\n })\n}\n\nconst wrapInEmptySignedTx = (tx) => buildTx({ encodedTx: tx, signatures: [] }, TX_TYPE.signed)\n\n/**\n * Create a metaTx transaction\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * @param {String} rawTransaction Inner transaction\n * @param {Object} authData Object with gaMeta params\n * @param {String} authFnName - Authorization function name\n * @param {Object} options - Options\n * @return {String}\n */\nasync function createMetaTx (rawTransaction, authData, authFnName, options = {}) {\n if (!authData) throw new Error('authData is required')\n // Check if authData is callData or if it's an object prepare a callData from source and args\n const { authCallData, gas } = await prepareGaParams(this)(authData, authFnName)\n const opt = { ...this.Ae.defaults, ...options }\n const { abiVersion } = await this.getVmVersion(TX_TYPE.contractCall)\n const wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction))\n const params = {\n ...opt,\n tx: {\n ...wrappedTx,\n tx: wrappedTx.txObject\n },\n gaId: await this.address(opt),\n abiVersion: abiVersion,\n authData: authCallData,\n gas,\n vsn: 2\n }\n const { fee } = await this.prepareTxParams(TX_TYPE.gaMeta, params)\n const { rlpEncoded: metaTxRlp } = buildTx(\n { ...params, fee: `${fee}` },\n TX_TYPE.gaMeta,\n { vsn: 2 }\n )\n return wrapInEmptySignedTx(metaTxRlp).tx\n}\n"],"file":"index.js"}
|
package/es/contract/index.js
CHANGED
|
@@ -36,7 +36,7 @@ import { required } from '@stamp/required';
|
|
|
36
36
|
* @return {Object} Contract instance
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const ContractBase = stampit(required({
|
|
40
40
|
methods: {
|
|
41
41
|
contractEncodeCallDataAPI: required,
|
|
42
42
|
compileContractAPI: required,
|
package/es/contract/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contract/index.js"],"names":["stampit","required","ContractBase","methods","contractEncodeCallDataAPI","compileContractAPI","contractGetACI","setCompilerUrl","getCompilerVersion","contractDecodeCallResultAPI","validateByteCodeAPI","getFateAssembler","getBytecodeCompilerVersion"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,
|
|
1
|
+
{"version":3,"sources":["../../src/contract/index.js"],"names":["stampit","required","ContractBase","methods","contractEncodeCallDataAPI","compileContractAPI","contractGetACI","setCompilerUrl","getCompilerVersion","contractDecodeCallResultAPI","validateByteCodeAPI","getFateAssembler","getBytecodeCompilerVersion"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAGF,OAAO,CAACC,QAAQ,CAAC;AACpCE,EAAAA,OAAO,EAAE;AACPC,IAAAA,yBAAyB,EAAEH,QADpB;AAEPI,IAAAA,kBAAkB,EAAEJ,QAFb;AAGPK,IAAAA,cAAc,EAAEL,QAHT;AAIPM,IAAAA,cAAc,EAAEN,QAJT;AAKPO,IAAAA,kBAAkB,EAAEP,QALb;AAMPQ,IAAAA,2BAA2B,EAAER,QANtB;AAOPS,IAAAA,mBAAmB,EAAET,QAPd;AAQPU,IAAAA,gBAAgB,EAAEV,QARX;AASPW,IAAAA,0BAA0B,EAAEX;AATrB;AAD2B,CAAD,CAAT,CAA5B;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAeC,YAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 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 * Contract Base module\n * @module @aeternity/aepp-sdk/es/contract\n * @export Contract\n * @example import ContractBase from '@aeternity/aepp-sdk/es/contract'\n */\n\nimport stampit from '@stamp/it'\nimport { required } from '@stamp/required'\n\n/**\n * Basic Contract Stamp\n *\n * This stamp include api call's related to contract functionality.\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Contract instance\n */\nconst ContractBase = stampit(required({\n methods: {\n contractEncodeCallDataAPI: required,\n compileContractAPI: required,\n contractGetACI: required,\n setCompilerUrl: required,\n getCompilerVersion: required,\n contractDecodeCallResultAPI: required,\n validateByteCodeAPI: required,\n getFateAssembler: required,\n getBytecodeCompilerVersion: required\n }\n}))\n\n/**\n * Get contract ACI\n * @function contractGetACI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, options: Array) => aciObject: Promise[Object]\n * @param {String} source - Contract source code\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Object} - Contract aci object\n */\n\n/**\n * Encode contract data\n * @function contractEncodeCallDataAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, name: String, args: Array, options: Array) => callData: Promise[String]\n * @param {String} source - Contract source code\n * @param {String} name - Function name\n * @param {Array} args - Function argument's\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Contract encoded data\n */\n\n/**\n * Decode contract call result data\n * @function contractDecodeCallResultAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, fn: String, callValue: String, callResult: String, options: Array) => decodedResult: Promise[String]\n * @param {String} source - Contract source\n * @param {String} fn - Fn name\n * @param {String} callValue - result data (cb_das...)\n * @param {String} callResult - contract call result status('ok', 'revert', ...)\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Decoded contract call result\n */\n\n/**\n * Decode call data by source\n * @function contractDecodeCallDataBySourceAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, function: String, callData: String, options: Array) => decodedResult: Promise[String]\n * @param {String} source - contract source\n * @param {String} function - function name\n * @param {String} callData - Encoded contract call data\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Decoded contract call data\n */\n\n/**\n * Decode call data by bytecode\n * @function contractDecodeCallDataByCodeAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (code: String, callData: String) => decodedResult: Promise[String]\n * @param {String} code - contract byte code\n * @param {String} callData - Encoded contract call data\n * @return {String} - Decoded contract call data\n */\n\n/**\n * Compile contract\n * @function compileContractAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (code: String, options?: Object) => compiledContract: Object\n * @param {String} code - Contract source code\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Object} Object which contain bytecode of contract\n */\n\n/**\n * Set compiler url\n * @function setCompilerUrl\n * @instance\n * @abstract\n * @category async\n * @rtype (url: String) => void\n * @param {String} url - Compiler url\n * @return {void}\n */\n\n/**\n * Get Compiler Version\n * @function getCompilerVersion\n * @instance\n * @abstract\n * @category async\n * @rtype () => String\n * @return {String} Compiler version\n */\n\nexport default ContractBase\n"],"file":"index.js"}
|