@avail-project/ca-common 1.0.0-beta.6 → 1.0.0-beta.8
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/cjs/_polyfill.js +147 -0
- package/dist/cjs/data/chaindata.js +43 -29
- package/dist/cjs/data/chainid.js +4 -2
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/proto/client.js +48 -0
- package/dist/cjs/proto/definition.js +167 -448
- package/dist/cjs/proto/grpc.js +4 -9
- package/dist/cjs/rff/rff.js +0 -35
- package/dist/cjs/vaultcontracts/vaultcontracts.js +70 -29
- package/dist/cjs/xcs/autochoice.js +255 -0
- package/dist/esm/_polyfill.js +143 -0
- package/dist/esm/data/chaindata.js +43 -29
- package/dist/esm/data/chainid.js +4 -2
- package/dist/esm/index.js +13 -12
- package/dist/esm/proto/client.js +11 -0
- package/dist/esm/proto/definition.js +167 -448
- package/dist/esm/proto/grpc.js +4 -9
- package/dist/esm/rff/rff.js +0 -35
- package/dist/esm/vaultcontracts/vaultcontracts.js +70 -29
- package/dist/esm/xcs/autochoice.js +254 -0
- package/dist/types/_polyfill.d.ts +1 -0
- package/dist/types/index.d.ts +13 -12
- package/dist/types/proto/client.d.ts +2 -0
- package/dist/types/rff/rff.d.ts +0 -3
- package/dist/types/xcs/autochoice.d.ts +17 -0
- package/package.json +14 -8
- package/dist/cjs/fuelcontracts/ArcanaVault.js +0 -2407
- package/dist/cjs/fuelcontracts/ArcanaVaultFactory.js +0 -18
- package/dist/cjs/fuelcontracts/common.js +0 -3
- package/dist/cjs/fuelcontracts/index.js +0 -5
- package/dist/cjs/rff/fuel.js +0 -27
- package/dist/esm/fuelcontracts/ArcanaVault.js +0 -2402
- package/dist/esm/fuelcontracts/ArcanaVaultFactory.js +0 -14
- package/dist/esm/fuelcontracts/common.js +0 -2
- package/dist/esm/fuelcontracts/index.js +0 -2
- package/dist/esm/rff/fuel.js +0 -23
- package/dist/types/fuelcontracts/ArcanaVault.d.ts +0 -448
- package/dist/types/fuelcontracts/ArcanaVaultFactory.d.ts +0 -8
- package/dist/types/fuelcontracts/common.d.ts +0 -23
- package/dist/types/fuelcontracts/index.d.ts +0 -2
- package/dist/types/rff/fuel.d.ts +0 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as bufferModule from "buffer";
|
|
2
|
+
import { Buffer as DefaultBuffer } from "buffer";
|
|
3
|
+
const globalScope = globalThis;
|
|
4
|
+
let patched = false;
|
|
5
|
+
function collectBufferCtors() {
|
|
6
|
+
const candidates = new Set();
|
|
7
|
+
if (typeof DefaultBuffer === "function") {
|
|
8
|
+
candidates.add(DefaultBuffer);
|
|
9
|
+
}
|
|
10
|
+
const mod = bufferModule;
|
|
11
|
+
if (typeof mod?.Buffer === "function") {
|
|
12
|
+
candidates.add(mod.Buffer);
|
|
13
|
+
}
|
|
14
|
+
const defaultExport = mod?.default;
|
|
15
|
+
if (typeof defaultExport === "function") {
|
|
16
|
+
candidates.add(defaultExport);
|
|
17
|
+
}
|
|
18
|
+
else if (defaultExport &&
|
|
19
|
+
typeof defaultExport === "object" &&
|
|
20
|
+
typeof defaultExport.Buffer === "function") {
|
|
21
|
+
candidates.add(defaultExport.Buffer);
|
|
22
|
+
}
|
|
23
|
+
if (typeof globalScope.Buffer === "function") {
|
|
24
|
+
candidates.add(globalScope.Buffer);
|
|
25
|
+
}
|
|
26
|
+
return Array.from(candidates);
|
|
27
|
+
}
|
|
28
|
+
function assertOffset(buffer, offset) {
|
|
29
|
+
const numericOffset = Number(offset);
|
|
30
|
+
if (!Number.isFinite(numericOffset)) {
|
|
31
|
+
throw new TypeError("Offset must be a finite number");
|
|
32
|
+
}
|
|
33
|
+
const normalized = numericOffset >>> 0;
|
|
34
|
+
if (normalized !== numericOffset) {
|
|
35
|
+
throw new RangeError("Offset must be a non-negative integer");
|
|
36
|
+
}
|
|
37
|
+
if (normalized + 4 > buffer.length) {
|
|
38
|
+
throw new RangeError("Offset out of bounds");
|
|
39
|
+
}
|
|
40
|
+
return normalized;
|
|
41
|
+
}
|
|
42
|
+
function fallbackWriteUint32BE(value, offset = 0) {
|
|
43
|
+
const o = assertOffset(this, offset);
|
|
44
|
+
const normalized = Number(value) >>> 0;
|
|
45
|
+
this[o] = (normalized >>> 24) & 0xff;
|
|
46
|
+
this[o + 1] =
|
|
47
|
+
(normalized >>> 16) & 0xff;
|
|
48
|
+
this[o + 2] =
|
|
49
|
+
(normalized >>> 8) & 0xff;
|
|
50
|
+
this[o + 3] = normalized & 0xff;
|
|
51
|
+
return o + 4;
|
|
52
|
+
}
|
|
53
|
+
function fallbackWriteUint32LE(value, offset = 0) {
|
|
54
|
+
const o = assertOffset(this, offset);
|
|
55
|
+
const normalized = Number(value) >>> 0;
|
|
56
|
+
this[o] = normalized & 0xff;
|
|
57
|
+
this[o + 1] =
|
|
58
|
+
(normalized >>> 8) & 0xff;
|
|
59
|
+
this[o + 2] =
|
|
60
|
+
(normalized >>> 16) & 0xff;
|
|
61
|
+
this[o + 3] =
|
|
62
|
+
(normalized >>> 24) & 0xff;
|
|
63
|
+
return o + 4;
|
|
64
|
+
}
|
|
65
|
+
function fallbackReadUint32BE(offset = 0) {
|
|
66
|
+
const o = assertOffset(this, offset);
|
|
67
|
+
const store = this;
|
|
68
|
+
return ((store[o] * 0x1000000 +
|
|
69
|
+
((store[o + 1] << 16) | (store[o + 2] << 8) | store[o + 3])) >>>
|
|
70
|
+
0);
|
|
71
|
+
}
|
|
72
|
+
function fallbackReadUint32LE(offset = 0) {
|
|
73
|
+
const o = assertOffset(this, offset);
|
|
74
|
+
const store = this;
|
|
75
|
+
return ((store[o] |
|
|
76
|
+
(store[o + 1] << 8) |
|
|
77
|
+
(store[o + 2] << 16) |
|
|
78
|
+
(store[o + 3] * 0x1000000)) >>>
|
|
79
|
+
0);
|
|
80
|
+
}
|
|
81
|
+
function aliasOrDefine(proto, alias, canonical, fallback) {
|
|
82
|
+
const aliasKey = alias;
|
|
83
|
+
const canonicalKey = canonical;
|
|
84
|
+
const existingAlias = proto[aliasKey];
|
|
85
|
+
if (typeof existingAlias === "function") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const canonicalFn = proto[canonicalKey];
|
|
89
|
+
if (typeof canonicalFn === "function") {
|
|
90
|
+
Object.defineProperty(proto, aliasKey, {
|
|
91
|
+
value: canonicalFn,
|
|
92
|
+
writable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
Object.defineProperty(proto, aliasKey, {
|
|
98
|
+
value: fallback,
|
|
99
|
+
writable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function patchPrototype(bufferCtor) {
|
|
104
|
+
const proto = bufferCtor.prototype;
|
|
105
|
+
if (!proto) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
aliasOrDefine(proto, "writeUint32BE", "writeUInt32BE", fallbackWriteUint32BE);
|
|
109
|
+
aliasOrDefine(proto, "writeUint32LE", "writeUInt32LE", fallbackWriteUint32LE);
|
|
110
|
+
aliasOrDefine(proto, "readUint32BE", "readUInt32BE", fallbackReadUint32BE);
|
|
111
|
+
aliasOrDefine(proto, "readUint32LE", "readUInt32LE", fallbackReadUint32LE);
|
|
112
|
+
}
|
|
113
|
+
function ensureProcessEnv() {
|
|
114
|
+
if (!globalScope.process) {
|
|
115
|
+
globalScope.process = { env: { NODE_ENV: "production" } };
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const processValue = globalScope.process;
|
|
119
|
+
if (!processValue.env) {
|
|
120
|
+
processValue.env = { NODE_ENV: "production" };
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (typeof processValue.env.NODE_ENV === "undefined") {
|
|
124
|
+
processValue.env.NODE_ENV = "production";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function ensureBufferPolyfill() {
|
|
128
|
+
if (patched) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const candidates = collectBufferCtors();
|
|
132
|
+
candidates.forEach(patchPrototype);
|
|
133
|
+
const preferred = candidates[0];
|
|
134
|
+
if (preferred &&
|
|
135
|
+
(typeof globalScope.Buffer !== "function" ||
|
|
136
|
+
typeof globalScope.Buffer.prototype?.writeUint32BE !==
|
|
137
|
+
"function")) {
|
|
138
|
+
globalScope.Buffer = preferred;
|
|
139
|
+
}
|
|
140
|
+
ensureProcessEnv();
|
|
141
|
+
patched = true;
|
|
142
|
+
}
|
|
143
|
+
ensureBufferPolyfill();
|
|
@@ -533,6 +533,27 @@ const RawData = [
|
|
|
533
533
|
},
|
|
534
534
|
],
|
|
535
535
|
},
|
|
536
|
+
{
|
|
537
|
+
Universe: 0,
|
|
538
|
+
ChainID32: "0x000000000000000000000000000000000000000000000000000000000000008f",
|
|
539
|
+
Currencies: [
|
|
540
|
+
{
|
|
541
|
+
CurrencyID: 1,
|
|
542
|
+
TokenContractAddress: "0x000000000000000000000000754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
543
|
+
PermitVariant: PermitVariant.EIP2612Canonical,
|
|
544
|
+
PermitContractVersion: 2,
|
|
545
|
+
TokenDecimals: 6,
|
|
546
|
+
IsGasToken: false,
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
CurrencyID: 20,
|
|
550
|
+
TokenContractAddress: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
551
|
+
PermitVariant: PermitVariant.Unsupported,
|
|
552
|
+
TokenDecimals: 18,
|
|
553
|
+
IsGasToken: true,
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
},
|
|
536
557
|
{
|
|
537
558
|
Universe: 3,
|
|
538
559
|
ChainID32: "0x0000000000000000000000000000000000000000000000000000000094a9059e",
|
|
@@ -603,75 +624,68 @@ export const ChaindataMap = new ChainIDKeyedMap(Chaindata.map((ch) => [ch.ChainI
|
|
|
603
624
|
export const RPCURLMap = new ChainIDKeyedMap([
|
|
604
625
|
[
|
|
605
626
|
new OmniversalChainID(Universe.ETHEREUM, 421614),
|
|
606
|
-
"https://
|
|
627
|
+
"https://rpcs.avail.so/arbitrumsepolia",
|
|
607
628
|
],
|
|
608
629
|
[
|
|
609
630
|
new OmniversalChainID(Universe.ETHEREUM, 11155420),
|
|
610
|
-
"https://
|
|
631
|
+
"https://rpcs.avail.so/optimismsepolia",
|
|
611
632
|
],
|
|
612
633
|
[
|
|
613
634
|
new OmniversalChainID(Universe.ETHEREUM, 80002),
|
|
614
|
-
"https://
|
|
635
|
+
"https://rpcs.avail.so/polygonamoy",
|
|
615
636
|
],
|
|
616
637
|
[
|
|
617
638
|
new OmniversalChainID(Universe.ETHEREUM, 84532),
|
|
618
|
-
"https://
|
|
639
|
+
"https://rpcs.avail.so/basesepolia",
|
|
619
640
|
],
|
|
620
641
|
[
|
|
621
642
|
new OmniversalChainID(Universe.ETHEREUM, 11155111),
|
|
622
|
-
"https://
|
|
643
|
+
"https://rpcs.avail.so/sepolia",
|
|
623
644
|
],
|
|
624
645
|
[
|
|
625
646
|
new OmniversalChainID(Universe.ETHEREUM, 137),
|
|
626
|
-
"https://
|
|
647
|
+
"https://rpcs.avail.so/polygon",
|
|
627
648
|
],
|
|
628
649
|
[
|
|
629
650
|
new OmniversalChainID(Universe.ETHEREUM, 42161),
|
|
630
|
-
"https://
|
|
651
|
+
"https://rpcs.avail.so/arbitrum",
|
|
631
652
|
],
|
|
632
653
|
[
|
|
633
654
|
new OmniversalChainID(Universe.ETHEREUM, 10),
|
|
634
|
-
"https://
|
|
655
|
+
"https://rpcs.avail.so/optimism",
|
|
635
656
|
],
|
|
636
657
|
[
|
|
637
658
|
new OmniversalChainID(Universe.ETHEREUM, 8453),
|
|
638
|
-
"https://
|
|
639
|
-
],
|
|
640
|
-
[
|
|
641
|
-
new OmniversalChainID(Universe.ETHEREUM, 1),
|
|
642
|
-
"https://eth-mainnet.g.alchemy.com/v2/PfaswrKq0rjOrfYWHfE9uLQKhiD4JCdq",
|
|
659
|
+
"https://rpcs.avail.so/base",
|
|
643
660
|
],
|
|
661
|
+
[new OmniversalChainID(Universe.ETHEREUM, 1), "https://rpcs.avail.so/eth"],
|
|
644
662
|
[
|
|
645
663
|
new OmniversalChainID(Universe.ETHEREUM, 534352),
|
|
646
|
-
"https://
|
|
647
|
-
],
|
|
648
|
-
[
|
|
649
|
-
new OmniversalChainID(Universe.ETHEREUM, 59144),
|
|
650
|
-
"https://linea-mainnet.g.alchemy.com/v2/PfaswrKq0rjOrfYWHfE9uLQKhiD4JCdq",
|
|
664
|
+
"https://rpcs.avail.so/scroll",
|
|
651
665
|
],
|
|
652
666
|
[
|
|
653
667
|
new OmniversalChainID(Universe.ETHEREUM, 43114),
|
|
654
|
-
"https://
|
|
668
|
+
"https://rpcs.avail.so/avalanche",
|
|
655
669
|
],
|
|
656
670
|
[
|
|
657
671
|
new OmniversalChainID(Universe.ETHEREUM, 999),
|
|
658
|
-
"https://
|
|
659
|
-
],
|
|
672
|
+
"https://rpcs.avail.so/hyperevm",
|
|
673
|
+
],
|
|
660
674
|
[
|
|
661
675
|
new OmniversalChainID(Universe.ETHEREUM, 8217),
|
|
662
|
-
"https://
|
|
663
|
-
],
|
|
664
|
-
[new OmniversalChainID(Universe.ETHEREUM, 50104), "https://rpc.sophon.xyz"], // Alchemy doesn't support this.
|
|
676
|
+
"https://rpcs.avail.so/kaia",
|
|
677
|
+
],
|
|
665
678
|
[
|
|
666
|
-
new OmniversalChainID(Universe.ETHEREUM,
|
|
667
|
-
"https://
|
|
679
|
+
new OmniversalChainID(Universe.ETHEREUM, 50104),
|
|
680
|
+
"https://sophon.gateway.tenderly.co/1d4STFT7zmG0vM5QowibCw",
|
|
668
681
|
],
|
|
682
|
+
[new OmniversalChainID(Universe.ETHEREUM, 56), "https://rpcs.avail.so/bsc"],
|
|
669
683
|
[
|
|
670
684
|
new OmniversalChainID(Universe.ETHEREUM, 10143),
|
|
671
|
-
"https://
|
|
685
|
+
"https://rpcs.avail.so/monadtestnet",
|
|
672
686
|
],
|
|
673
687
|
[
|
|
674
|
-
new OmniversalChainID(Universe.
|
|
675
|
-
"https://
|
|
688
|
+
new OmniversalChainID(Universe.ETHEREUM, 143),
|
|
689
|
+
"https://rpcs.avail.so/monad",
|
|
676
690
|
],
|
|
677
691
|
]);
|
package/dist/esm/data/chainid.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ensureBufferPolyfill } from "../_polyfill";
|
|
1
2
|
import { bytesToBigInt, bytesToHex, hexToBigInt, hexToBytes, toBytes, toHex, } from "viem";
|
|
2
3
|
import { universeFromJSON, universeToJSON, } from "../proto/definition";
|
|
3
4
|
import { convertToBufferIfNecessary } from "./utils";
|
|
5
|
+
ensureBufferPolyfill();
|
|
4
6
|
export function encodeChainID36(universe, chainID) {
|
|
5
7
|
let chainIDB;
|
|
6
8
|
if (Buffer.isBuffer(chainID) || chainID instanceof Uint8Array) {
|
|
@@ -10,7 +12,7 @@ export function encodeChainID36(universe, chainID) {
|
|
|
10
12
|
chainIDB = toBytes(chainID);
|
|
11
13
|
}
|
|
12
14
|
const buf = Buffer.alloc(36);
|
|
13
|
-
buf.
|
|
15
|
+
buf.writeUInt32BE(universe);
|
|
14
16
|
buf.set(chainIDB, 4 + (32 - chainIDB.length));
|
|
15
17
|
return buf;
|
|
16
18
|
}
|
|
@@ -45,7 +47,7 @@ export class OmniversalChainID {
|
|
|
45
47
|
}
|
|
46
48
|
static fromChainID36(_input) {
|
|
47
49
|
const input = convertToBufferIfNecessary(_input);
|
|
48
|
-
const univID = input.
|
|
50
|
+
const univID = input.readUInt32BE(0);
|
|
49
51
|
const rest = input.subarray(4);
|
|
50
52
|
return new OmniversalChainID(univID, rest);
|
|
51
53
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
export { QueryClientImpl, GrpcWebError, GrpcWebImpl } from
|
|
4
|
-
export
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
1
|
+
import "./_polyfill";
|
|
2
|
+
export * from "./proto/definition";
|
|
3
|
+
export { QueryClientImpl, GrpcWebError, GrpcWebImpl, } from "./proto/grpc";
|
|
4
|
+
export { createGrpcWebImpl } from "./proto/client";
|
|
5
|
+
export * from "./data";
|
|
6
|
+
export * from "./vaultcontracts";
|
|
7
|
+
export * from "./permitutils";
|
|
8
|
+
export * from "./xcs";
|
|
9
|
+
export * from "./cosmos";
|
|
10
|
+
export * from "./rff/rff";
|
|
11
|
+
export * from "./types";
|
|
12
|
+
export * from "./balances/ub-api";
|
|
13
|
+
export * from "./evmabi";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GrpcWebImpl } from "./grpc";
|
|
2
|
+
export const createGrpcWebImpl = async (url) => {
|
|
3
|
+
const options = {};
|
|
4
|
+
// eslint-disable-next-line no-constant-binary-expression, valid-typeof
|
|
5
|
+
if (typeof window == undefined) {
|
|
6
|
+
const lib = await import("@improbable-eng/grpc-web-node-http-transport");
|
|
7
|
+
options.transport = lib.NodeHttpTransport();
|
|
8
|
+
}
|
|
9
|
+
const impl = new GrpcWebImpl(url, options);
|
|
10
|
+
return impl;
|
|
11
|
+
};
|