@aeternity/aepp-sdk 13.3.1 → 13.3.3
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/bin/aesophia_cli_8 +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +50 -45
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdkAepp.mjs +1 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +4 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/chain.d.ts +5 -5
- package/es/chain.mjs +18 -20
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +1 -1
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/internal.d.ts +23 -17
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.mjs +3 -0
- package/es/contract/Contract.mjs.map +1 -1
- package/es/oracle.d.ts +2 -2
- package/es/oracle.mjs +6 -10
- package/es/oracle.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.mjs +1 -4
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/ttl.d.ts +3 -2
- package/es/tx/builder/field-types/ttl.mjs.map +1 -1
- package/es/tx/builder/helpers.mjs +9 -0
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +69 -46
- package/es/utils/hd-wallet.d.ts +2 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -1
- package/es/utils/semver-satisfies.mjs +8 -9
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/package.json +5 -4
- package/src/AeSdkAepp.ts +1 -1
- package/src/AeSdkWallet.ts +2 -1
- package/src/chain.ts +28 -18
- package/src/channel/Base.ts +1 -1
- package/src/channel/internal.ts +24 -17
- package/src/contract/Contract.ts +3 -0
- package/src/oracle.ts +7 -7
- package/src/tx/builder/field-types/gas-price.ts +67 -70
- package/src/tx/builder/field-types/ttl.ts +1 -1
- package/src/tx/builder/helpers.ts +9 -0
- package/src/utils/hd-wallet.ts +5 -3
- package/src/utils/semver-satisfies.ts +14 -13
- package/types-legacy/ts4.2/chain.d.ts +5 -5
- package/types-legacy/ts4.2/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.2/channel/internal.d.ts +23 -17
- package/types-legacy/ts4.2/oracle.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +69 -46
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -1
- package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -1
- package/types-legacy/ts4.5/chain.d.ts +5 -5
- package/types-legacy/ts4.5/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.5/channel/internal.d.ts +23 -17
- package/types-legacy/ts4.5/oracle.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +69 -46
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -1
- package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -1
package/dist/aepp-sdk.js
CHANGED
|
@@ -7784,6 +7784,15 @@ function nameToPunycode(maybeName) {
|
|
|
7784
7784
|
if (/\p{Emoji_Presentation}/u.test(name)) {
|
|
7785
7785
|
throw new ArgumentError('aens name', 'not containing emoji', maybeName);
|
|
7786
7786
|
}
|
|
7787
|
+
if (name[2] === '-' && name[3] === '-') {
|
|
7788
|
+
throw new ArgumentError('aens name', 'without "-" char in both the third and fourth positions', maybeName);
|
|
7789
|
+
}
|
|
7790
|
+
if (name[0] === '-') {
|
|
7791
|
+
throw new ArgumentError('aens name', 'starting with no "-" char', maybeName);
|
|
7792
|
+
}
|
|
7793
|
+
if (name.at(-1) === '-') {
|
|
7794
|
+
throw new ArgumentError('aens name', 'ending with no "-" char', maybeName);
|
|
7795
|
+
}
|
|
7787
7796
|
let punycode;
|
|
7788
7797
|
try {
|
|
7789
7798
|
const u = new URL(`http://${name}.${suffix}`);
|
|
@@ -7943,16 +7952,20 @@ function isAuctionName(name) {
|
|
|
7943
7952
|
* @param type - Type
|
|
7944
7953
|
* @param options - Options
|
|
7945
7954
|
*/
|
|
7946
|
-
function _getPollInterval(type,
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
_microBlockCycle = 3000
|
|
7955
|
+
async function _getPollInterval(type, {
|
|
7956
|
+
_expectedMineRate,
|
|
7957
|
+
_microBlockCycle,
|
|
7958
|
+
onNode
|
|
7951
7959
|
}) {
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7960
|
+
var _ref, _await$getVal;
|
|
7961
|
+
const getVal = async (t, val, devModeDef, def) => {
|
|
7962
|
+
if (t !== type) return null;
|
|
7963
|
+
if (val != null) return val;
|
|
7964
|
+
return (await (onNode === null || onNode === void 0 ? void 0 : onNode.getNetworkId())) === 'ae_dev' ? devModeDef : def;
|
|
7965
|
+
};
|
|
7966
|
+
const base = (_ref = (_await$getVal = await getVal('key-block', _expectedMineRate, 0, 180000)) !== null && _await$getVal !== void 0 ? _await$getVal : await getVal('micro-block', _microBlockCycle, 0, 3000)) !== null && _ref !== void 0 ? _ref : (() => {
|
|
7967
|
+
throw new InternalError(`Unknown type: ${type}`);
|
|
7968
|
+
})();
|
|
7956
7969
|
return Math.floor(base / 3);
|
|
7957
7970
|
}
|
|
7958
7971
|
const heightCache = new WeakMap();
|
|
@@ -7973,7 +7986,7 @@ async function getHeight({
|
|
|
7973
7986
|
const onNode = unwrapProxy(options.onNode);
|
|
7974
7987
|
if (cached) {
|
|
7975
7988
|
const cache = heightCache.get(onNode);
|
|
7976
|
-
if (cache != null && cache.time > Date.now() - _getPollInterval('block', options)) {
|
|
7989
|
+
if (cache != null && cache.time > Date.now() - (await _getPollInterval('key-block', options))) {
|
|
7977
7990
|
return cache.height;
|
|
7978
7991
|
}
|
|
7979
7992
|
}
|
|
@@ -8002,26 +8015,23 @@ async function getHeight({
|
|
|
8002
8015
|
async function poll(th, {
|
|
8003
8016
|
blocks = 5,
|
|
8004
8017
|
interval,
|
|
8005
|
-
onNode,
|
|
8006
8018
|
...options
|
|
8007
8019
|
}) {
|
|
8008
8020
|
var _interval;
|
|
8009
|
-
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = _getPollInterval('
|
|
8021
|
+
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = await _getPollInterval('micro-block', options);
|
|
8010
8022
|
let max;
|
|
8011
8023
|
do {
|
|
8012
|
-
const tx = await onNode.getTransactionByHash(th);
|
|
8024
|
+
const tx = await options.onNode.getTransactionByHash(th);
|
|
8013
8025
|
if (tx.blockHeight !== -1) return tx;
|
|
8014
8026
|
if (max == null) {
|
|
8015
8027
|
max = tx.tx.ttl !== 0 ? -1 : (await getHeight({
|
|
8016
8028
|
...options,
|
|
8017
|
-
onNode,
|
|
8018
8029
|
cached: true
|
|
8019
8030
|
})) + blocks;
|
|
8020
8031
|
}
|
|
8021
8032
|
await pause(interval);
|
|
8022
8033
|
} while (max === -1 ? true : (await getHeight({
|
|
8023
8034
|
...options,
|
|
8024
|
-
onNode,
|
|
8025
8035
|
cached: true
|
|
8026
8036
|
})) < max);
|
|
8027
8037
|
throw new TxTimedOutError(blocks, th);
|
|
@@ -8038,17 +8048,14 @@ async function poll(th, {
|
|
|
8038
8048
|
*/
|
|
8039
8049
|
async function awaitHeight(height, {
|
|
8040
8050
|
interval,
|
|
8041
|
-
onNode,
|
|
8042
8051
|
...options
|
|
8043
8052
|
}) {
|
|
8044
8053
|
var _interval2;
|
|
8045
|
-
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = Math.min(_getPollInterval('block', options), 5000);
|
|
8054
|
+
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = Math.min(await _getPollInterval('key-block', options), 5000);
|
|
8046
8055
|
let currentHeight;
|
|
8047
8056
|
do {
|
|
8048
8057
|
if (currentHeight != null) await pause(interval);
|
|
8049
|
-
currentHeight = await getHeight(
|
|
8050
|
-
onNode
|
|
8051
|
-
});
|
|
8058
|
+
currentHeight = await getHeight(options);
|
|
8052
8059
|
} while (currentHeight < height);
|
|
8053
8060
|
return currentHeight;
|
|
8054
8061
|
}
|
|
@@ -8669,17 +8676,16 @@ function genEncodedField(encoding, optional) {
|
|
|
8669
8676
|
}
|
|
8670
8677
|
});
|
|
8671
8678
|
;// CONCATENATED MODULE: ./src/utils/semver-satisfies.ts
|
|
8672
|
-
function
|
|
8679
|
+
function verCmp(a, b) {
|
|
8673
8680
|
const getComponents = v => v.split(/[-+]/)[0].split('.').map(i => +i);
|
|
8674
|
-
const
|
|
8675
|
-
const
|
|
8676
|
-
const
|
|
8677
|
-
const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;
|
|
8681
|
+
const aComponents = getComponents(a);
|
|
8682
|
+
const bComponents = getComponents(b);
|
|
8683
|
+
const base = Math.max(...aComponents, ...bComponents) + 1;
|
|
8678
8684
|
const componentsToNumber = components => components.reverse().reduce((acc, n, idx) => acc + n * base ** idx, 0);
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
return
|
|
8685
|
+
return componentsToNumber(aComponents) - componentsToNumber(bComponents);
|
|
8686
|
+
}
|
|
8687
|
+
function semverSatisfies(version, geVersion, ltVersion) {
|
|
8688
|
+
return verCmp(version, geVersion) >= 0 && (ltVersion == null || verCmp(version, ltVersion) < 0);
|
|
8683
8689
|
}
|
|
8684
8690
|
;// CONCATENATED MODULE: ./src/tx/builder/field-types/gas-price.ts
|
|
8685
8691
|
|
|
@@ -8699,10 +8705,7 @@ async function getCachedIncreasedGasPrice(node) {
|
|
|
8699
8705
|
const {
|
|
8700
8706
|
nodeVersion
|
|
8701
8707
|
} = await node._getCachedStatus();
|
|
8702
|
-
|
|
8703
|
-
if (!nodeVersion.startsWith('6.12.0+') && !semverSatisfies(nodeVersion, '6.13.0', '8.0.0')) {
|
|
8704
|
-
return 0n;
|
|
8705
|
-
}
|
|
8708
|
+
if (!semverSatisfies(nodeVersion, '6.13.0')) return 0n;
|
|
8706
8709
|
const {
|
|
8707
8710
|
minGasPrice,
|
|
8708
8711
|
utilization
|
|
@@ -18392,6 +18395,9 @@ function _getCallResult2({
|
|
|
18392
18395
|
break;
|
|
18393
18396
|
case 'error':
|
|
18394
18397
|
message = decode(returnValue).toString();
|
|
18398
|
+
if (/Expected \d+ arguments, got \d+/.test(message)) {
|
|
18399
|
+
throw new ContractError(`ACI doesn't match called contract. Error provided by node: ${message}`);
|
|
18400
|
+
}
|
|
18395
18401
|
break;
|
|
18396
18402
|
default:
|
|
18397
18403
|
throw new InternalError(`Unknown return type: ${returnType}`);
|
|
@@ -18483,15 +18489,12 @@ const ContractWithMethods = Contract;
|
|
|
18483
18489
|
*/
|
|
18484
18490
|
function pollForQueries(oracleId, onQuery, {
|
|
18485
18491
|
interval,
|
|
18486
|
-
onNode,
|
|
18487
18492
|
...options
|
|
18488
18493
|
}) {
|
|
18489
|
-
var _interval;
|
|
18490
|
-
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = _getPollInterval('microblock', options);
|
|
18491
18494
|
const knownQueryIds = new Set();
|
|
18492
18495
|
const checkNewQueries = async () => {
|
|
18493
|
-
var _await$onNode
|
|
18494
|
-
const queries = ((_await$onNode
|
|
18496
|
+
var _await$options$onNode;
|
|
18497
|
+
const queries = ((_await$options$onNode = (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries) !== null && _await$options$onNode !== void 0 ? _await$options$onNode : []).filter(({
|
|
18495
18498
|
id
|
|
18496
18499
|
}) => !knownQueryIds.has(id));
|
|
18497
18500
|
queries.forEach(query => {
|
|
@@ -18502,7 +18505,8 @@ function pollForQueries(oracleId, onQuery, {
|
|
|
18502
18505
|
let stopped = false;
|
|
18503
18506
|
|
|
18504
18507
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
18505
|
-
(async
|
|
18508
|
+
(async _interval => {
|
|
18509
|
+
(_interval = interval) !== null && _interval !== void 0 ? _interval : interval = await _getPollInterval('micro-block', options);
|
|
18506
18510
|
while (!stopped) {
|
|
18507
18511
|
// eslint-disable-line no-unmodified-loop-condition
|
|
18508
18512
|
// TODO: allow to handle this error somehow
|
|
@@ -18527,11 +18531,10 @@ function pollForQueries(oracleId, onQuery, {
|
|
|
18527
18531
|
*/
|
|
18528
18532
|
async function pollForQueryResponse(oracleId, queryId, {
|
|
18529
18533
|
interval,
|
|
18530
|
-
onNode,
|
|
18531
18534
|
...options
|
|
18532
18535
|
}) {
|
|
18533
18536
|
var _interval2;
|
|
18534
|
-
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('
|
|
18537
|
+
(_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = await _getPollInterval('micro-block', options);
|
|
18535
18538
|
let height;
|
|
18536
18539
|
let ttl;
|
|
18537
18540
|
let response;
|
|
@@ -18539,13 +18542,12 @@ async function pollForQueryResponse(oracleId, queryId, {
|
|
|
18539
18542
|
({
|
|
18540
18543
|
response,
|
|
18541
18544
|
ttl
|
|
18542
|
-
} = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));
|
|
18545
|
+
} = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));
|
|
18543
18546
|
const responseBuffer = decode(response);
|
|
18544
18547
|
if (responseBuffer.length > 0) return responseBuffer.toString();
|
|
18545
18548
|
await pause(interval);
|
|
18546
18549
|
height = await getHeight({
|
|
18547
18550
|
...options,
|
|
18548
|
-
onNode,
|
|
18549
18551
|
cached: true
|
|
18550
18552
|
});
|
|
18551
18553
|
} while (ttl >= height);
|
|
@@ -20080,7 +20082,7 @@ class AeSdkAepp extends AeSdkBase {
|
|
|
20080
20082
|
* @returns Addresses from wallet
|
|
20081
20083
|
*/
|
|
20082
20084
|
async askAddresses() {
|
|
20083
|
-
this.
|
|
20085
|
+
this._ensureConnected();
|
|
20084
20086
|
return this.rpcClient.request(METHODS.address, undefined);
|
|
20085
20087
|
}
|
|
20086
20088
|
|
|
@@ -20473,11 +20475,14 @@ class AeSdkWallet extends AeSdk {
|
|
|
20473
20475
|
* @returns Object with wallet information
|
|
20474
20476
|
*/
|
|
20475
20477
|
async getWalletInfo() {
|
|
20478
|
+
const {
|
|
20479
|
+
origin
|
|
20480
|
+
} = window.location;
|
|
20476
20481
|
return {
|
|
20477
20482
|
id: this.id,
|
|
20478
20483
|
name: this.name,
|
|
20479
20484
|
networkId: await this.api.getNetworkId(),
|
|
20480
|
-
origin:
|
|
20485
|
+
origin: origin === 'file://' ? '*' : origin,
|
|
20481
20486
|
type: this._type
|
|
20482
20487
|
};
|
|
20483
20488
|
}
|