@aeternity/aepp-sdk 12.0.0 → 12.1.2
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 -15
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20765 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -7
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +4 -3
- package/es/AeSdkAepp.mjs +2 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +22 -21
- package/es/AeSdkBase.mjs +25 -21
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkWallet.d.ts +4 -3
- package/es/AeSdkWallet.mjs +5 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +7 -10
- package/es/Node.mjs +63 -57
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +7 -4
- package/es/account/Base.mjs +3 -3
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Memory.d.ts +5 -4
- package/es/account/Memory.mjs +24 -2
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -6
- package/es/account/Rpc.mjs +3 -2
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +27 -14
- package/es/aens.mjs +27 -21
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.d.ts +2 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +5 -2
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +5 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.d.ts +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -5
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +8 -8
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +17 -2
- package/es/aepp-wallet-communication/schema.mjs +54 -17
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +2 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +6 -2
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.mjs +4 -2
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/chain.d.ts +92 -64
- package/es/chain.mjs +190 -154
- package/es/chain.mjs.map +1 -1
- package/es/channel/handlers.d.ts +3 -3
- package/es/channel/handlers.mjs +42 -44
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +43 -52
- package/es/channel/index.mjs +46 -49
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +16 -15
- package/es/channel/internal.mjs +67 -62
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +1 -0
- package/es/contract/Compiler.mjs +5 -4
- package/es/contract/Compiler.mjs.map +1 -1
- package/es/contract/aci.d.ts +17 -15
- package/es/contract/aci.mjs +58 -45
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +16 -15
- package/es/contract/ga.mjs +12 -7
- package/es/contract/ga.mjs.map +1 -1
- package/es/contract/methods.d.ts +9 -6
- package/es/contract/methods.mjs +9 -6
- package/es/contract/methods.mjs.map +1 -1
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +4 -1
- package/es/index.mjs +4 -1
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +69 -62
- package/es/oracle.mjs +121 -103
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +16 -15
- package/es/spend.mjs +19 -30
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +55 -26
- package/es/tx/builder/constants.mjs +60 -38
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/{min-fee.mjs → builder/field-types/fee.mjs} +62 -60
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +27 -33
- package/es/tx/builder/helpers.mjs +41 -47
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +25 -12
- package/es/tx/builder/index.mjs +74 -83
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +995 -144
- package/es/tx/builder/schema.mjs +121 -170
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +28 -27
- package/es/tx/index.mjs +97 -117
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +4 -3
- package/es/tx/validator.mjs +79 -92
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -1
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -1
- package/es/typings/bip32-path/index.d.mjs.map +1 -1
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -1
- package/es/utils/amount-formatter.d.ts +9 -9
- package/es/utils/amount-formatter.mjs +17 -17
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.mjs +7 -7
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +2 -1
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +8 -23
- package/es/utils/crypto.mjs +15 -41
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +6 -7
- package/es/utils/encoder.mjs +42 -26
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +1 -11
- package/es/utils/errors.mjs +4 -20
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +18 -2
- package/es/utils/hd-wallet.mjs +64 -34
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +2 -2
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs +4 -2
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/mptree.d.ts +2 -2
- package/es/utils/mptree.mjs +11 -6
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +8 -2
- package/es/utils/other.mjs +15 -3
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -1
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs.map +1 -1
- package/package.json +36 -34
- package/src/AeSdk.ts +30 -27
- package/src/AeSdkAepp.ts +93 -84
- package/src/AeSdkBase.ts +148 -130
- package/src/AeSdkWallet.ts +172 -156
- package/src/Node.ts +108 -102
- package/src/account/Base.ts +42 -32
- package/src/account/Memory.ts +45 -30
- package/src/account/Rpc.ts +32 -30
- package/src/aens.ts +124 -108
- package/src/aepp-wallet-communication/connection/Browser.ts +18 -15
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +22 -21
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +63 -52
- package/src/aepp-wallet-communication/connection-proxy.ts +8 -7
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +67 -61
- package/src/aepp-wallet-communication/rpc/types.ts +32 -32
- package/src/aepp-wallet-communication/schema.ts +117 -74
- package/src/aepp-wallet-communication/wallet-detector.ts +29 -28
- package/src/apis/node/code-model-v4.yaml +54 -20
- package/src/apis/node/models/index.ts +6 -2
- package/src/apis/node/models/mappers.ts +4 -2
- package/src/chain.ts +286 -228
- package/src/channel/handlers.ts +424 -372
- package/src/channel/index.ts +285 -251
- package/src/channel/internal.ts +248 -232
- package/src/contract/Compiler.ts +22 -21
- package/src/contract/aci.ts +267 -258
- package/src/contract/ga.ts +93 -72
- package/src/contract/methods.ts +32 -27
- package/src/deprecated/index.ts +172 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +37 -32
- package/src/oracle.ts +211 -189
- package/src/spend.ts +82 -70
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +82 -52
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +112 -117
- package/src/tx/builder/index.ts +203 -197
- package/src/tx/builder/schema.ts +421 -465
- package/src/tx/index.ts +128 -135
- package/src/tx/validator.ts +165 -161
- package/src/typings/@aeternity__argon2-browser/index.d.ts +1 -1
- package/src/typings/@aeternity__uuid/index.d.ts +3 -1
- package/src/typings/bip32-path/index.d.ts +6 -6
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +2 -2
- package/src/utils/amount-formatter.ts +41 -41
- package/src/utils/autorest.ts +57 -54
- package/src/utils/bignumber.ts +7 -6
- package/src/utils/bytes.ts +19 -19
- package/src/utils/crypto.ts +82 -94
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +104 -56
- package/src/utils/errors.ts +246 -264
- package/src/utils/hd-wallet.ts +114 -82
- package/src/utils/json-big.ts +16 -15
- package/src/utils/keystore.ts +65 -62
- package/src/utils/mptree.ts +59 -56
- package/src/utils/other.ts +26 -18
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +10 -10
- package/es/tx/builder/field-types.d.ts +0 -62
- package/es/tx/builder/field-types.mjs +0 -126
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/min-fee.d.ts +0 -20
- package/es/tx/min-fee.mjs.map +0 -1
- package/src/tx/builder/field-types.ts +0 -111
- package/src/tx/min-fee.ts +0 -136
package/es/oracle.d.ts
CHANGED
|
@@ -5,36 +5,19 @@
|
|
|
5
5
|
* https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
|
|
6
6
|
* repository.
|
|
7
7
|
*/
|
|
8
|
+
import BigNumber from 'bignumber.js';
|
|
8
9
|
import { send, SendOptions } from './spend';
|
|
9
|
-
import { ORACLE_TTL_TYPES
|
|
10
|
-
import {
|
|
10
|
+
import { ORACLE_TTL_TYPES } from './tx/builder/schema';
|
|
11
|
+
import { Tag } from './tx/builder/constants';
|
|
12
|
+
import { Encoded } from './utils/encoder';
|
|
11
13
|
import { _getPollInterval } from './chain';
|
|
12
14
|
import { BuildTxOptions } from './tx';
|
|
13
15
|
import Node from './Node';
|
|
14
|
-
import BigNumber from 'bignumber.js';
|
|
15
16
|
import AccountBase from './account/Base';
|
|
16
17
|
declare type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];
|
|
17
|
-
/**
|
|
18
|
-
* Constructor for Oracle Object (helper object for using Oracle)
|
|
19
|
-
* @param oracleId - Oracle public key
|
|
20
|
-
* @param options - Options
|
|
21
|
-
* @returns Oracle object
|
|
22
|
-
*/
|
|
23
|
-
export declare function getOracleObject(oracleId: EncodedData<'ok'>, options: {
|
|
24
|
-
onNode: Node;
|
|
25
|
-
onAccount: AccountBase;
|
|
26
|
-
}): Promise<GetOracleObjectReturnType>;
|
|
27
|
-
interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {
|
|
28
|
-
id: EncodedData<'ok'>;
|
|
29
|
-
queries: OracleQueries;
|
|
30
|
-
pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;
|
|
31
|
-
postQuery: Function;
|
|
32
|
-
respondToQuery: Function;
|
|
33
|
-
extendOracle: Function;
|
|
34
|
-
getQuery: Function;
|
|
35
|
-
}
|
|
36
18
|
/**
|
|
37
19
|
* Poll for oracle queries
|
|
20
|
+
* @category oracle
|
|
38
21
|
* @param oracleId - Oracle public key
|
|
39
22
|
* @param onQuery - OnQuery callback
|
|
40
23
|
* @param options - Options object
|
|
@@ -42,61 +25,42 @@ interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleBy
|
|
|
42
25
|
* @param options.onNode - Node to use
|
|
43
26
|
* @returns Callback to stop polling function
|
|
44
27
|
*/
|
|
45
|
-
export declare function pollForQueries(oracleId:
|
|
28
|
+
export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (queries: OracleQueries) => void, { interval, onNode, ...options }: {
|
|
46
29
|
interval?: number;
|
|
47
30
|
onNode: Node;
|
|
48
31
|
} & Parameters<typeof _getPollInterval>[1]): () => void;
|
|
49
|
-
/**
|
|
50
|
-
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
51
|
-
* @param oracleId - Oracle public key
|
|
52
|
-
* @param queryId - Oracle Query id
|
|
53
|
-
* @param options - Options
|
|
54
|
-
* @returns OracleQuery object
|
|
55
|
-
*/
|
|
56
|
-
export declare function getQueryObject(oracleId: EncodedData<'ok'>, queryId: EncodedData<'oq'>, options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2]): Promise<GetQueryObjectReturnType>;
|
|
57
|
-
interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
|
|
58
|
-
decodedQuery: string;
|
|
59
|
-
decodedResponse: string;
|
|
60
|
-
respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) => ReturnType<typeof respondToQuery>;
|
|
61
|
-
pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
|
|
62
|
-
}
|
|
63
32
|
/**
|
|
64
33
|
* Poll for oracle query response
|
|
34
|
+
* @category oracle
|
|
65
35
|
* @param oracleId - Oracle public key
|
|
66
36
|
* @param queryId - Oracle Query id
|
|
67
37
|
* @param options - Options object
|
|
68
|
-
* @param options.attempts - Poll attempts
|
|
69
38
|
* @param options.interval - Poll interval
|
|
70
39
|
* @param options.onNode - Node to use
|
|
71
40
|
* @returns OracleQuery object
|
|
72
41
|
*/
|
|
73
|
-
export declare function pollForQueryResponse(oracleId:
|
|
74
|
-
attempts?: number;
|
|
42
|
+
export declare function pollForQueryResponse(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, { interval, onNode, ...options }: {
|
|
75
43
|
interval?: number;
|
|
76
44
|
onNode: Node;
|
|
77
45
|
} & Parameters<typeof _getPollInterval>[1]): Promise<string>;
|
|
78
46
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @param
|
|
47
|
+
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
48
|
+
* @category oracle
|
|
49
|
+
* @param oracleId - Oracle public key
|
|
50
|
+
* @param queryId - Oracle Query id
|
|
82
51
|
* @param options - Options
|
|
83
|
-
* @
|
|
84
|
-
* @param options - Options object
|
|
85
|
-
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
86
|
-
* @param options.fee - Transaction fee
|
|
87
|
-
* @param options.ttl - Transaction time to leave
|
|
88
|
-
* @returns Oracle object
|
|
52
|
+
* @returns OracleQuery object
|
|
89
53
|
*/
|
|
90
|
-
export declare function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
interface RegisterOracleOptions extends RegisterOracleOptionsType {
|
|
54
|
+
export declare function getQueryObject(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2]): Promise<GetQueryObjectReturnType>;
|
|
55
|
+
interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
|
|
56
|
+
decodedQuery: string;
|
|
57
|
+
decodedResponse: string;
|
|
58
|
+
respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) => ReturnType<typeof respondToQuery>;
|
|
59
|
+
pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
|
|
97
60
|
}
|
|
98
61
|
/**
|
|
99
62
|
* Post query to oracle
|
|
63
|
+
* @category oracle
|
|
100
64
|
* @param oracleId - Oracle public key
|
|
101
65
|
* @param query - Oracle query object
|
|
102
66
|
* @param options - Options object
|
|
@@ -107,8 +71,8 @@ interface RegisterOracleOptions extends RegisterOracleOptionsType {
|
|
|
107
71
|
* @param options.ttl - Transaction time to leave
|
|
108
72
|
* @returns Query object
|
|
109
73
|
*/
|
|
110
|
-
export declare function postQueryToOracle(oracleId:
|
|
111
|
-
declare type PostQueryToOracleOptionsType = Parameters<typeof send>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<
|
|
74
|
+
export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>>;
|
|
75
|
+
declare type PostQueryToOracleOptionsType = Parameters<typeof send>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
112
76
|
queryTtlType?: ORACLE_TTL_TYPES;
|
|
113
77
|
queryTtlValue?: number;
|
|
114
78
|
responseTtlType?: ORACLE_TTL_TYPES;
|
|
@@ -118,6 +82,7 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
|
|
|
118
82
|
}
|
|
119
83
|
/**
|
|
120
84
|
* Extend oracle ttl
|
|
85
|
+
* @category oracle
|
|
121
86
|
* @param oracleId - Oracle public key
|
|
122
87
|
* @param options - Options object
|
|
123
88
|
* @param options.fee - fee Transaction fee
|
|
@@ -126,8 +91,8 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
|
|
|
126
91
|
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
127
92
|
* @returns Oracle object
|
|
128
93
|
*/
|
|
129
|
-
export declare function extendOracleTtl(oracleId:
|
|
130
|
-
declare type ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<
|
|
94
|
+
export declare function extendOracleTtl(oracleId: Encoded.OracleAddress, options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
95
|
+
declare type ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
|
|
131
96
|
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
132
97
|
oracleTtlValue?: number;
|
|
133
98
|
};
|
|
@@ -135,6 +100,7 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
|
|
|
135
100
|
}
|
|
136
101
|
/**
|
|
137
102
|
* Extend oracle ttl
|
|
103
|
+
* @category oracle
|
|
138
104
|
* @param oracleId - Oracle public key
|
|
139
105
|
* @param queryId - Oracle query id
|
|
140
106
|
* @param response - Oracle query response
|
|
@@ -144,11 +110,52 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
|
|
|
144
110
|
* @param options.ttl - Transaction time to leave
|
|
145
111
|
* @returns Oracle object
|
|
146
112
|
*/
|
|
147
|
-
export declare function respondToQuery(oracleId:
|
|
148
|
-
declare type RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<
|
|
113
|
+
export declare function respondToQuery(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
114
|
+
declare type RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
|
|
149
115
|
responseTtlType?: ORACLE_TTL_TYPES;
|
|
150
116
|
responseTtlValue?: number;
|
|
151
117
|
};
|
|
152
118
|
interface RespondToQueryOptions extends RespondToQueryOptionsType {
|
|
153
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Constructor for Oracle Object (helper object for using Oracle)
|
|
122
|
+
* @category oracle
|
|
123
|
+
* @param oracleId - Oracle public key
|
|
124
|
+
* @param options - Options
|
|
125
|
+
* @returns Oracle object
|
|
126
|
+
*/
|
|
127
|
+
export declare function getOracleObject(oracleId: Encoded.OracleAddress, options: {
|
|
128
|
+
onNode: Node;
|
|
129
|
+
onAccount: AccountBase;
|
|
130
|
+
}): Promise<GetOracleObjectReturnType>;
|
|
131
|
+
interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {
|
|
132
|
+
id: Encoded.OracleAddress;
|
|
133
|
+
queries: OracleQueries;
|
|
134
|
+
pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;
|
|
135
|
+
postQuery: Function;
|
|
136
|
+
respondToQuery: Function;
|
|
137
|
+
extendOracle: Function;
|
|
138
|
+
getQuery: Function;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Register oracle
|
|
142
|
+
* @category oracle
|
|
143
|
+
* @param queryFormat - Format of query
|
|
144
|
+
* @param responseFormat - Format of query response
|
|
145
|
+
* @param options - Options
|
|
146
|
+
* @param options.queryFee - Oracle query Fee
|
|
147
|
+
* @param options - Options object
|
|
148
|
+
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
149
|
+
* @param options.fee - Transaction fee
|
|
150
|
+
* @param options.ttl - Transaction time to leave
|
|
151
|
+
* @returns Oracle object
|
|
152
|
+
*/
|
|
153
|
+
export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
|
|
154
|
+
declare type RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'> & {
|
|
155
|
+
queryFee?: number | string | BigNumber;
|
|
156
|
+
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
157
|
+
oracleTtlValue?: number;
|
|
158
|
+
};
|
|
159
|
+
interface RegisterOracleOptions extends RegisterOracleOptionsType {
|
|
160
|
+
}
|
|
154
161
|
export {};
|
package/es/oracle.mjs
CHANGED
|
@@ -24,51 +24,18 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { send } from "./spend.mjs";
|
|
26
26
|
import { mapObject, pause } from "./utils/other.mjs";
|
|
27
|
-
import { oracleQueryId
|
|
27
|
+
import { oracleQueryId } from "./tx/builder/helpers.mjs";
|
|
28
28
|
import { unpackTx } from "./tx/builder/index.mjs";
|
|
29
|
-
import { ORACLE_TTL, QUERY_FEE, QUERY_TTL, RESPONSE_TTL
|
|
29
|
+
import { ORACLE_TTL, QUERY_FEE, QUERY_TTL, RESPONSE_TTL } from "./tx/builder/schema.mjs";
|
|
30
|
+
import { Tag } from "./tx/builder/constants.mjs";
|
|
30
31
|
import { RequestTimedOutError } from "./utils/errors.mjs";
|
|
32
|
+
import { decode, encode, Encoding } from "./utils/encoder.mjs";
|
|
31
33
|
import { _getPollInterval } from "./chain.mjs";
|
|
32
34
|
import { _buildTx } from "./tx/index.mjs";
|
|
33
35
|
|
|
34
|
-
/**
|
|
35
|
-
* Constructor for Oracle Object (helper object for using Oracle)
|
|
36
|
-
* @param oracleId - Oracle public key
|
|
37
|
-
* @param options - Options
|
|
38
|
-
* @returns Oracle object
|
|
39
|
-
*/
|
|
40
|
-
export async function getOracleObject(oracleId, options) {
|
|
41
|
-
return { ...(await options.onNode.getOracleByPubkey(oracleId)),
|
|
42
|
-
queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,
|
|
43
|
-
...mapObject({
|
|
44
|
-
pollQueries: pollForQueries,
|
|
45
|
-
postQuery: postQueryToOracle,
|
|
46
|
-
respondToQuery,
|
|
47
|
-
extendOracle: extendOracleTtl,
|
|
48
|
-
getQuery: getQueryObject
|
|
49
|
-
}, _ref => {
|
|
50
|
-
let [name, handler] = _ref;
|
|
51
|
-
return [name, function () {
|
|
52
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
-
args[_key] = arguments[_key];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const lastArg = args[args.length - 1];
|
|
57
|
-
|
|
58
|
-
if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {
|
|
59
|
-
Object.assign(lastArg, { ...options,
|
|
60
|
-
...lastArg
|
|
61
|
-
});
|
|
62
|
-
} else args.push(options);
|
|
63
|
-
|
|
64
|
-
return handler(oracleId, ...args);
|
|
65
|
-
}];
|
|
66
|
-
})
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
36
|
/**
|
|
71
37
|
* Poll for oracle queries
|
|
38
|
+
* @category oracle
|
|
72
39
|
* @param oracleId - Oracle public key
|
|
73
40
|
* @param onQuery - OnQuery callback
|
|
74
41
|
* @param options - Options object
|
|
@@ -76,30 +43,30 @@ export async function getOracleObject(oracleId, options) {
|
|
|
76
43
|
* @param options.onNode - Node to use
|
|
77
44
|
* @returns Callback to stop polling function
|
|
78
45
|
*/
|
|
79
|
-
export function pollForQueries(oracleId, onQuery,
|
|
46
|
+
export function pollForQueries(oracleId, onQuery, _ref) {
|
|
80
47
|
var _interval;
|
|
81
48
|
|
|
82
49
|
let {
|
|
83
50
|
interval,
|
|
84
51
|
onNode,
|
|
85
52
|
...options
|
|
86
|
-
} =
|
|
53
|
+
} = _ref;
|
|
87
54
|
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = _getPollInterval('microblock', options);
|
|
88
55
|
const knownQueryIds = new Set();
|
|
89
56
|
|
|
90
57
|
const checkNewQueries = async () => {
|
|
91
58
|
var _await$onNode$getOrac;
|
|
92
59
|
|
|
93
|
-
const queries = ((_await$onNode$getOrac = (await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries) !== null && _await$onNode$getOrac !== void 0 ? _await$onNode$getOrac : []).filter(
|
|
60
|
+
const queries = ((_await$onNode$getOrac = (await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries) !== null && _await$onNode$getOrac !== void 0 ? _await$onNode$getOrac : []).filter(_ref2 => {
|
|
94
61
|
let {
|
|
95
62
|
id
|
|
96
|
-
} =
|
|
63
|
+
} = _ref2;
|
|
97
64
|
return !knownQueryIds.has(id);
|
|
98
65
|
});
|
|
99
|
-
queries.forEach(
|
|
66
|
+
queries.forEach(_ref3 => {
|
|
100
67
|
let {
|
|
101
68
|
id
|
|
102
|
-
} =
|
|
69
|
+
} = _ref3;
|
|
103
70
|
return knownQueryIds.add(id);
|
|
104
71
|
});
|
|
105
72
|
if (queries.length > 0) onQuery(queries);
|
|
@@ -120,91 +87,70 @@ export function pollForQueries(oracleId, onQuery, _ref2) {
|
|
|
120
87
|
stopped = true;
|
|
121
88
|
};
|
|
122
89
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
125
|
-
* @param oracleId - Oracle public key
|
|
126
|
-
* @param queryId - Oracle Query id
|
|
127
|
-
* @param options - Options
|
|
128
|
-
* @returns OracleQuery object
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
export async function getQueryObject(oracleId, queryId, options) {
|
|
132
|
-
const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);
|
|
133
|
-
return { ...record,
|
|
134
|
-
decodedQuery: decode(record.query).toString(),
|
|
135
|
-
decodedResponse: decode(record.response).toString(),
|
|
136
|
-
respond: async (response, opt) => await respondToQuery(oracleId, queryId, response, { ...options,
|
|
137
|
-
...opt
|
|
138
|
-
}),
|
|
139
|
-
pollForResponse: async opt => await pollForQueryResponse(oracleId, queryId, { ...options,
|
|
140
|
-
...opt
|
|
141
|
-
})
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
90
|
/**
|
|
146
91
|
* Poll for oracle query response
|
|
92
|
+
* @category oracle
|
|
147
93
|
* @param oracleId - Oracle public key
|
|
148
94
|
* @param queryId - Oracle Query id
|
|
149
95
|
* @param options - Options object
|
|
150
|
-
* @param options.attempts - Poll attempts
|
|
151
96
|
* @param options.interval - Poll interval
|
|
152
97
|
* @param options.onNode - Node to use
|
|
153
98
|
* @returns OracleQuery object
|
|
154
99
|
*/
|
|
155
|
-
|
|
100
|
+
|
|
101
|
+
export async function pollForQueryResponse(oracleId, queryId, _ref4) {
|
|
156
102
|
var _interval2;
|
|
157
103
|
|
|
158
104
|
let {
|
|
159
|
-
attempts = 20,
|
|
160
105
|
interval,
|
|
161
106
|
onNode,
|
|
162
107
|
...options
|
|
163
|
-
} =
|
|
108
|
+
} = _ref4;
|
|
164
109
|
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('microblock', options);
|
|
110
|
+
let height;
|
|
111
|
+
let ttl;
|
|
112
|
+
let response;
|
|
165
113
|
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
response
|
|
170
|
-
|
|
114
|
+
do {
|
|
115
|
+
if (height != null) await pause(interval);
|
|
116
|
+
({
|
|
117
|
+
response,
|
|
118
|
+
ttl
|
|
119
|
+
} = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));
|
|
171
120
|
const responseBuffer = decode(response);
|
|
172
121
|
if (responseBuffer.length > 0) return responseBuffer.toString();
|
|
173
|
-
|
|
122
|
+
height = await this.getHeight();
|
|
123
|
+
} while (ttl >= height);
|
|
174
124
|
|
|
175
|
-
throw new RequestTimedOutError(
|
|
125
|
+
throw new RequestTimedOutError(height);
|
|
176
126
|
}
|
|
177
127
|
/**
|
|
178
|
-
*
|
|
179
|
-
* @
|
|
180
|
-
* @param
|
|
128
|
+
* Constructor for OracleQuery Object (helper object for using OracleQuery)
|
|
129
|
+
* @category oracle
|
|
130
|
+
* @param oracleId - Oracle public key
|
|
131
|
+
* @param queryId - Oracle Query id
|
|
181
132
|
* @param options - Options
|
|
182
|
-
* @
|
|
183
|
-
* @param options - Options object
|
|
184
|
-
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
185
|
-
* @param options.fee - Transaction fee
|
|
186
|
-
* @param options.ttl - Transaction time to leave
|
|
187
|
-
* @returns Oracle object
|
|
133
|
+
* @returns OracleQuery object
|
|
188
134
|
*/
|
|
189
135
|
|
|
190
|
-
export async function
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
...options,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
...(await getOracleObject(encode(decode(accountId), 'ok'), options))
|
|
136
|
+
export async function getQueryObject(oracleId, queryId, options) {
|
|
137
|
+
const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);
|
|
138
|
+
return { ...record,
|
|
139
|
+
decodedQuery: decode(record.query).toString(),
|
|
140
|
+
decodedResponse: decode(record.response).toString(),
|
|
141
|
+
respond: async (response, opt) => // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
142
|
+
respondToQuery(oracleId, queryId, response, { ...options,
|
|
143
|
+
...opt
|
|
144
|
+
}),
|
|
145
|
+
pollForResponse: async opt => pollForQueryResponse(oracleId, queryId, { ...options,
|
|
146
|
+
...opt
|
|
147
|
+
})
|
|
203
148
|
};
|
|
204
149
|
}
|
|
205
150
|
|
|
206
151
|
/**
|
|
207
152
|
* Post query to oracle
|
|
153
|
+
* @category oracle
|
|
208
154
|
* @param oracleId - Oracle public key
|
|
209
155
|
* @param query - Oracle query object
|
|
210
156
|
* @param options - Options object
|
|
@@ -220,7 +166,7 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
220
166
|
|
|
221
167
|
(_options$queryFee = options.queryFee) !== null && _options$queryFee !== void 0 ? _options$queryFee : options.queryFee = (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
|
|
222
168
|
const senderId = await options.onAccount.address(options);
|
|
223
|
-
const oracleQueryTx = await _buildTx(
|
|
169
|
+
const oracleQueryTx = await _buildTx(Tag.OracleQueryTx, {
|
|
224
170
|
queryTtlType: QUERY_TTL.type,
|
|
225
171
|
queryTtlValue: QUERY_TTL.value,
|
|
226
172
|
responseTtlType: RESPONSE_TTL.type,
|
|
@@ -230,7 +176,9 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
230
176
|
senderId,
|
|
231
177
|
query
|
|
232
178
|
});
|
|
233
|
-
const
|
|
179
|
+
const {
|
|
180
|
+
nonce
|
|
181
|
+
} = unpackTx(oracleQueryTx, Tag.OracleQueryTx).tx;
|
|
234
182
|
const queryId = oracleQueryId(senderId, nonce, oracleId);
|
|
235
183
|
return { ...(await send(oracleQueryTx, options)),
|
|
236
184
|
...(await getQueryObject(oracleId, queryId, options))
|
|
@@ -239,6 +187,7 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
239
187
|
|
|
240
188
|
/**
|
|
241
189
|
* Extend oracle ttl
|
|
190
|
+
* @category oracle
|
|
242
191
|
* @param oracleId - Oracle public key
|
|
243
192
|
* @param options - Options object
|
|
244
193
|
* @param options.fee - fee Transaction fee
|
|
@@ -248,7 +197,7 @@ export async function postQueryToOracle(oracleId, query, options) {
|
|
|
248
197
|
* @returns Oracle object
|
|
249
198
|
*/
|
|
250
199
|
export async function extendOracleTtl(oracleId, options) {
|
|
251
|
-
const oracleExtendTx = await _buildTx(
|
|
200
|
+
const oracleExtendTx = await _buildTx(Tag.OracleExtendTx, {
|
|
252
201
|
oracleTtlType: ORACLE_TTL.type,
|
|
253
202
|
oracleTtlValue: ORACLE_TTL.value,
|
|
254
203
|
...options,
|
|
@@ -256,12 +205,14 @@ export async function extendOracleTtl(oracleId, options) {
|
|
|
256
205
|
oracleId
|
|
257
206
|
});
|
|
258
207
|
return { ...(await send(oracleExtendTx, options)),
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
259
209
|
...(await getOracleObject(oracleId, options))
|
|
260
210
|
};
|
|
261
211
|
}
|
|
262
212
|
|
|
263
213
|
/**
|
|
264
214
|
* Extend oracle ttl
|
|
215
|
+
* @category oracle
|
|
265
216
|
* @param oracleId - Oracle public key
|
|
266
217
|
* @param queryId - Oracle query id
|
|
267
218
|
* @param response - Oracle query response
|
|
@@ -272,7 +223,7 @@ export async function extendOracleTtl(oracleId, options) {
|
|
|
272
223
|
* @returns Oracle object
|
|
273
224
|
*/
|
|
274
225
|
export async function respondToQuery(oracleId, queryId, response, options) {
|
|
275
|
-
const oracleRespondTx = await _buildTx(
|
|
226
|
+
const oracleRespondTx = await _buildTx(Tag.OracleResponseTx, {
|
|
276
227
|
responseTtlType: RESPONSE_TTL.type,
|
|
277
228
|
responseTtlValue: RESPONSE_TTL.value,
|
|
278
229
|
...options,
|
|
@@ -282,7 +233,74 @@ export async function respondToQuery(oracleId, queryId, response, options) {
|
|
|
282
233
|
response
|
|
283
234
|
});
|
|
284
235
|
return { ...(await send(oracleRespondTx, options)),
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
285
237
|
...(await getOracleObject(oracleId, options))
|
|
286
238
|
};
|
|
287
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Constructor for Oracle Object (helper object for using Oracle)
|
|
243
|
+
* @category oracle
|
|
244
|
+
* @param oracleId - Oracle public key
|
|
245
|
+
* @param options - Options
|
|
246
|
+
* @returns Oracle object
|
|
247
|
+
*/
|
|
248
|
+
export async function getOracleObject(oracleId, options) {
|
|
249
|
+
return { ...(await options.onNode.getOracleByPubkey(oracleId)),
|
|
250
|
+
queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,
|
|
251
|
+
...mapObject({
|
|
252
|
+
pollQueries: pollForQueries,
|
|
253
|
+
postQuery: postQueryToOracle,
|
|
254
|
+
respondToQuery,
|
|
255
|
+
extendOracle: extendOracleTtl,
|
|
256
|
+
getQuery: getQueryObject
|
|
257
|
+
}, _ref5 => {
|
|
258
|
+
let [name, handler] = _ref5;
|
|
259
|
+
return [name, function () {
|
|
260
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
261
|
+
args[_key] = arguments[_key];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const lastArg = args[args.length - 1];
|
|
265
|
+
|
|
266
|
+
if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {
|
|
267
|
+
Object.assign(lastArg, { ...options,
|
|
268
|
+
...lastArg
|
|
269
|
+
});
|
|
270
|
+
} else args.push(options);
|
|
271
|
+
|
|
272
|
+
return handler(oracleId, ...args);
|
|
273
|
+
}];
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Register oracle
|
|
280
|
+
* @category oracle
|
|
281
|
+
* @param queryFormat - Format of query
|
|
282
|
+
* @param responseFormat - Format of query response
|
|
283
|
+
* @param options - Options
|
|
284
|
+
* @param options.queryFee - Oracle query Fee
|
|
285
|
+
* @param options - Options object
|
|
286
|
+
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
287
|
+
* @param options.fee - Transaction fee
|
|
288
|
+
* @param options.ttl - Transaction time to leave
|
|
289
|
+
* @returns Oracle object
|
|
290
|
+
*/
|
|
291
|
+
export async function registerOracle(queryFormat, responseFormat, options) {
|
|
292
|
+
const accountId = await options.onAccount.address(options);
|
|
293
|
+
const oracleRegisterTx = await _buildTx(Tag.OracleRegisterTx, {
|
|
294
|
+
queryFee: QUERY_FEE,
|
|
295
|
+
oracleTtlValue: ORACLE_TTL.value,
|
|
296
|
+
oracleTtlType: ORACLE_TTL.type,
|
|
297
|
+
...options,
|
|
298
|
+
accountId,
|
|
299
|
+
queryFormat,
|
|
300
|
+
responseFormat
|
|
301
|
+
});
|
|
302
|
+
return { ...(await send(oracleRegisterTx, options)),
|
|
303
|
+
...(await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options))
|
|
304
|
+
};
|
|
305
|
+
}
|
|
288
306
|
//# sourceMappingURL=oracle.mjs.map
|