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