@aeternity/aepp-sdk 8.2.0 → 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/README.md +16 -9
- 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 +33 -119
- 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 +75 -154
- 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 +108 -916
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +89 -250
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +132 -500
- package/es/ae/oracle.js.map +1 -1
- package/es/chain/index.js +4 -23
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +292 -1018
- 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 -491
- 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 +17 -122
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +102 -247
- 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 +2 -3
- 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 +49 -89
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +205 -303
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +585 -573
- 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 -135
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +810 -1586
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +191 -426
- 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 +354 -603
- 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 +49 -75
- 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 -218
- package/es/utils/swagger.js.map +1 -1
- package/package.json +52 -43
- package/src/account/base.js +8 -9
- package/src/account/multiple.js +20 -16
- package/src/ae/aens.js +25 -21
- package/src/ae/contract.js +65 -246
- package/src/ae/index.js +31 -7
- package/src/ae/oracle.js +21 -17
- package/src/chain/index.js +2 -12
- package/src/chain/node.js +26 -29
- package/src/channel/handlers.js +0 -1
- package/src/channel/index.js +4 -5
- package/src/contract/aci/index.js +221 -106
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +45 -4
- package/src/contract/ga/helpers.js +2 -12
- package/src/contract/ga/index.js +22 -26
- package/src/index.js +2 -4
- package/src/node-pool/index.js +21 -12
- package/src/node.js +22 -26
- package/src/tx/builder/helpers.js +12 -24
- package/src/tx/builder/index.js +18 -15
- package/src/tx/builder/schema.js +43 -108
- package/src/tx/tx-object.js +0 -2
- package/src/tx/tx.js +157 -144
- package/src/tx/validator.js +134 -202
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +9 -10
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/amount-formatter.ts +1 -1
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/crypto.js +4 -17
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +24 -7
- package/CHANGELOG.md +0 -1716
- package/src/contract/aci/helpers.js +0 -140
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda'
|
|
2
|
-
import { unpackTx } from '../../tx/builder'
|
|
3
|
-
import { decodeEvents as unpackEvents, transform, transformDecodedData, validateArguments } from './transformation'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get function schema from contract ACI object
|
|
7
|
-
* @param {Object} aci Contract ACI object
|
|
8
|
-
* @param {String} name Function name
|
|
9
|
-
* @param external
|
|
10
|
-
* @return {Object} function ACI
|
|
11
|
-
*/
|
|
12
|
-
export function getFunctionACI (aci, name, { external }) {
|
|
13
|
-
if (!aci) throw new Error('ACI required')
|
|
14
|
-
const fn = aci.functions.find(f => f.name === name)
|
|
15
|
-
if (!fn && name !== 'init') throw new Error(`Function ${name} doesn't exist in contract`)
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
...fn,
|
|
19
|
-
bindings: [
|
|
20
|
-
{
|
|
21
|
-
state: aci.state,
|
|
22
|
-
type_defs: aci.type_defs,
|
|
23
|
-
name: aci.name
|
|
24
|
-
},
|
|
25
|
-
...external.map(R.pick(['state', 'type_defs', 'name']))
|
|
26
|
-
],
|
|
27
|
-
event: aci.event ? aci.event.variant : []
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Build contract methods base on ACI
|
|
33
|
-
* @return {Object} Contract instance methods
|
|
34
|
-
*/
|
|
35
|
-
export const buildContractMethods = (instance) => () => ({
|
|
36
|
-
...instance.aci
|
|
37
|
-
? instance
|
|
38
|
-
.aci
|
|
39
|
-
.functions
|
|
40
|
-
.reduce(
|
|
41
|
-
(acc, { name, arguments: aciArgs, stateful }) => ({
|
|
42
|
-
...acc,
|
|
43
|
-
[name]: Object.assign(
|
|
44
|
-
function () {
|
|
45
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
46
|
-
if (name === 'init') return instance.deploy(args, opt)
|
|
47
|
-
return instance.call(name, args, { callStatic: !stateful, ...opt })
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
get () {
|
|
51
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
52
|
-
return instance.call(name, args, { ...opt, callStatic: true })
|
|
53
|
-
},
|
|
54
|
-
send () {
|
|
55
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
56
|
-
if (name === 'init') return instance.deploy(args, opt)
|
|
57
|
-
return instance.call(name, args, { ...opt, callStatic: false })
|
|
58
|
-
},
|
|
59
|
-
decodeEvents (events) {
|
|
60
|
-
return instance.decodeEvents(name, events)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
}),
|
|
65
|
-
{}
|
|
66
|
-
)
|
|
67
|
-
: {},
|
|
68
|
-
...instance.aci ? {
|
|
69
|
-
init: Object.assign(
|
|
70
|
-
function () {
|
|
71
|
-
const { arguments: aciArgs } = getFunctionACI(instance.aci, 'init', { external: instance.externalAci })
|
|
72
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
73
|
-
return instance.deploy(args, opt)
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
get () {
|
|
77
|
-
const { arguments: aciArgs } = getFunctionACI(instance.aci, 'init', { external: instance.externalAci })
|
|
78
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
79
|
-
return instance.deploy(args, { ...opt, callStatic: true })
|
|
80
|
-
},
|
|
81
|
-
send () {
|
|
82
|
-
const { arguments: aciArgs } = getFunctionACI(instance.aci, 'init', { external: instance.externalAci })
|
|
83
|
-
const { opt, args } = parseArguments(aciArgs)(arguments)
|
|
84
|
-
return instance.deploy(args, { ...opt, callStatic: false })
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
} : {}
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
export const parseArguments = (aciArgs = []) => (args) => ({
|
|
92
|
-
opt: args.length > aciArgs.length ? R.last(args) : {},
|
|
93
|
-
args: Object.values(args).slice(0, aciArgs.length)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
export const unpackByteCode = (bytecode) => unpackTx(bytecode, false, 'cb').tx
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Validated contract call arguments using contract ACI
|
|
100
|
-
* @function validateCallParams
|
|
101
|
-
* @rtype (aci: Object, params: Array) => Object
|
|
102
|
-
* @param {Object} aci Contract ACI
|
|
103
|
-
* @param {Array} params Contract call arguments
|
|
104
|
-
* @return Promise{Array} Object with validation errors
|
|
105
|
-
*/
|
|
106
|
-
export const prepareArgsForEncode = async (aci, params) => {
|
|
107
|
-
if (!aci || !aci.arguments) return params
|
|
108
|
-
// Validation
|
|
109
|
-
if (aci.arguments.length > params.length) {
|
|
110
|
-
throw new Error(`Function "${aci.name}" require ${aci.arguments.length} arguments of types [${aci.arguments.map(a => JSON.stringify(a.type))}] but get [${params.map(JSON.stringify)}]`)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
validateArguments(aci, params)
|
|
114
|
-
const bindings = aci.bindings
|
|
115
|
-
// Cast argument from JS to Sophia type
|
|
116
|
-
return Promise.all(aci.arguments.map(async ({ type }, i) => transform(type, params[i], {
|
|
117
|
-
bindings
|
|
118
|
-
})))
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const decodeEvents = (events, fnACI) => {
|
|
122
|
-
if (!fnACI || !fnACI.event || !fnACI.event.length) return []
|
|
123
|
-
|
|
124
|
-
const eventsSchema = fnACI.event.map(e => {
|
|
125
|
-
const name = Object.keys(e)[0]
|
|
126
|
-
return { name, types: e[name] }
|
|
127
|
-
})
|
|
128
|
-
return unpackEvents(events, { schema: eventsSchema })
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export const decodeCallResult = async (result, fnACI, opt) => {
|
|
132
|
-
return {
|
|
133
|
-
decodedResult: await transformDecodedData(
|
|
134
|
-
fnACI.returns,
|
|
135
|
-
await result.decode(),
|
|
136
|
-
{ ...opt, bindings: fnACI.bindings }
|
|
137
|
-
),
|
|
138
|
-
decodedEvents: decodeEvents(result.result.log, fnACI)
|
|
139
|
-
}
|
|
140
|
-
}
|