@xyo-network/xl1-protocol-sdk 1.15.21 → 1.15.23
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/neutral/eip-712/Payloads/EIP712Data.d.ts +39 -0
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts.map +1 -0
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts +22 -0
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts.map +1 -0
- package/dist/neutral/eip-712/Payloads/index.d.ts +3 -0
- package/dist/neutral/eip-712/Payloads/index.d.ts.map +1 -0
- package/dist/neutral/eip-712/Types.d.ts +21 -4
- package/dist/neutral/eip-712/Types.d.ts.map +1 -1
- package/dist/neutral/eip-712/index.d.ts +1 -1
- package/dist/neutral/eip-712/index.d.ts.map +1 -1
- package/dist/neutral/eip-712/sign.d.ts +2 -2
- package/dist/neutral/eip-712/sign.d.ts.map +1 -1
- package/dist/neutral/eip-712/spec/fixtures.d.ts +2 -2
- package/dist/neutral/eip-712/spec/fixtures.d.ts.map +1 -1
- package/dist/neutral/eip-712/verify.d.ts +2 -3
- package/dist/neutral/eip-712/verify.d.ts.map +1 -1
- package/dist/neutral/index.mjs +105 -39
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/block/primitives/blockFromBlockNumber.ts +2 -2
- package/src/config/storage/driver/Mongo.ts +5 -5
- package/src/eip-712/Payloads/EIP712Data.ts +45 -0
- package/src/eip-712/Payloads/EIP712Signature.ts +24 -0
- package/src/eip-712/Payloads/index.ts +2 -0
- package/src/eip-712/Types.ts +26 -4
- package/src/eip-712/index.ts +1 -1
- package/src/eip-712/sign.ts +9 -6
- package/src/eip-712/spec/fixtures.ts +5 -5
- package/src/eip-712/spec/signAndVerify.spec.ts +1 -1
- package/src/eip-712/verify.ts +13 -5
- package/dist/neutral/eip-712/Payload.d.ts +0 -24
- package/dist/neutral/eip-712/Payload.d.ts.map +0 -1
- package/src/eip-712/Payload.ts +0 -31
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Payload } from '@xyo-network/payload-model';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
export declare const EIP712DataPayloadFieldsZod: z.ZodObject<{
|
|
4
|
+
domain: z.ZodObject<{
|
|
5
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
chainId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBigInt]>>>;
|
|
8
|
+
verifyingContract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
salt: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>>>;
|
|
10
|
+
}, z.z.core.$strip>;
|
|
11
|
+
types: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
type: z.ZodString;
|
|
14
|
+
}, z.z.core.$strip>>>;
|
|
15
|
+
values: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
16
|
+
}, z.z.core.$strip>;
|
|
17
|
+
export type EIP712DataPayloadFields = z.infer<typeof EIP712DataPayloadFieldsZod>;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use EIP712DataPayloadFields instead
|
|
20
|
+
*/
|
|
21
|
+
export type EIP712PayloadFields = EIP712DataPayloadFields;
|
|
22
|
+
export declare const EIP712DataPayloadSchema: "network.xyo.chains.ethereum.eip712.data";
|
|
23
|
+
export type EIP712DataPayloadSchema = typeof EIP712DataPayloadSchema;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use EIP712DataPayloadSchema instead
|
|
26
|
+
*/
|
|
27
|
+
export declare const EIP712PayloadSchema: "network.xyo.chains.ethereum.eip712.data";
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use EIP712DataPayloadSchema instead
|
|
30
|
+
*/
|
|
31
|
+
export type EIP712PayloadSchema = typeof EIP712DataPayloadSchema;
|
|
32
|
+
export type EIP712DataPayload = Payload<EIP712DataPayloadFields, EIP712DataPayloadSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use EIP712DataPayload instead
|
|
35
|
+
*/
|
|
36
|
+
export type EIP712Payload = EIP712DataPayload;
|
|
37
|
+
export declare const isEIP712DataPayload: (x?: unknown | null) => x is EIP712DataPayload;
|
|
38
|
+
export declare const asEIP712DataPayload: import("@xylabs/object").AsTypeFunction<EIP712DataPayload>;
|
|
39
|
+
//# sourceMappingURL=EIP712Data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712Data.d.ts","sourceRoot":"","sources":["../../../../src/eip-712/Payloads/EIP712Data.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,CAAC,MAAM,KAAK,CAAA;AAMnB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;mBAIrC,CAAA;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEhF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAA;AAEzD,eAAO,MAAM,uBAAuB,EAAG,yCAAkD,CAAA;AACzF,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,mBAAmB,2CAA0B,CAAA;AAC1D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,uBAAuB,CAAA;AAEhE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,CAAA;AAEzF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAE7C,eAAO,MAAM,mBAAmB,gDAG/B,CAAA;AAED,eAAO,MAAM,mBAAmB,4DAA8C,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Payload } from '@xyo-network/payload-model';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
export declare const EIP712SignaturePayloadFieldsZod: z.ZodObject<{
|
|
4
|
+
address: z.ZodString;
|
|
5
|
+
hash: z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
6
|
+
readonly __hex: true;
|
|
7
|
+
}>, {
|
|
8
|
+
readonly __hash: true;
|
|
9
|
+
}>, unknown, z.z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
|
|
10
|
+
readonly __hex: true;
|
|
11
|
+
}>, {
|
|
12
|
+
readonly __hash: true;
|
|
13
|
+
}>, unknown>>;
|
|
14
|
+
signature: z.ZodString;
|
|
15
|
+
}, z.z.core.$strip>;
|
|
16
|
+
export type EIP712SignaturePayloadFields = z.infer<typeof EIP712SignaturePayloadFieldsZod>;
|
|
17
|
+
export declare const EIP712SignaturePayloadSchema: "network.xyo.chains.ethereum.eip712.signature";
|
|
18
|
+
export type EIP712SignaturePayloadSchema = typeof EIP712SignaturePayloadSchema;
|
|
19
|
+
export type EIP712SignaturePayload = Payload<EIP712SignaturePayloadFields, EIP712SignaturePayloadSchema>;
|
|
20
|
+
export declare const isEIP712SignaturePayload: (x?: unknown | null) => x is EIP712SignaturePayload;
|
|
21
|
+
export declare const asEIP712SignaturePayload: import("@xylabs/object").AsTypeFunction<EIP712SignaturePayload>;
|
|
22
|
+
//# sourceMappingURL=EIP712Signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712Signature.d.ts","sourceRoot":"","sources":["../../../../src/eip-712/Payloads/EIP712Signature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,+BAA+B;;;;;;;;;;;;mBAI1C,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAE1F,eAAO,MAAM,4BAA4B,EAAG,8CAAuD,CAAA;AACnG,MAAM,MAAM,4BAA4B,GAAG,OAAO,4BAA4B,CAAA;AAE9E,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAA;AAExG,eAAO,MAAM,wBAAwB,qDAGpC,CAAA;AAED,eAAO,MAAM,wBAAwB,iEAAmD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/eip-712/Payloads/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Typed Data Types
|
|
4
4
|
* Re-exposing the types from ethers for convenience and to ensure
|
|
5
5
|
* we can fix in one place if they change
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare const TypedDataDomainZod: z.ZodObject<{
|
|
8
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
chainId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBigInt]>>>;
|
|
11
|
+
verifyingContract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
salt: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>>>;
|
|
13
|
+
}, z.z.core.$strip>;
|
|
14
|
+
export type TypedDataDomain = z.infer<typeof TypedDataDomainZod>;
|
|
15
|
+
export declare const TypedDataFieldZod: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
}, z.z.core.$strip>;
|
|
19
|
+
export type TypedDataField = z.infer<typeof TypedDataFieldZod>;
|
|
20
|
+
export declare const TypedDataTypesZod: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
type: z.ZodString;
|
|
23
|
+
}, z.z.core.$strip>>>;
|
|
24
|
+
export type TypedDataTypes = z.infer<typeof TypedDataTypesZod>;
|
|
25
|
+
export declare const TypedDataValueZod: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
26
|
+
export type TypedDataValues = z.infer<typeof TypedDataValueZod>;
|
|
10
27
|
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/eip-712/Types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/eip-712/Types.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB;;;;GAIG;AAMH,eAAO,MAAM,kBAAkB;;;;;;mBAM7B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEhE,eAAO,MAAM,iBAAiB;;;mBAG5B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE9D,eAAO,MAAM,iBAAiB;;;qBAAmD,CAAA;AACjF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE9D,eAAO,MAAM,iBAAiB,oCAAgC,CAAA;AAC9D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eip-712/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eip-712/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Signer } from 'ethers/providers';
|
|
2
|
-
import { type
|
|
3
|
-
export declare const signEIP712Message: (signer: Signer, data:
|
|
2
|
+
import { type EIP712DataPayload, type EIP712SignaturePayload } from './Payloads/index.ts';
|
|
3
|
+
export declare const signEIP712Message: (signer: Signer, data: EIP712DataPayload) => Promise<EIP712SignaturePayload>;
|
|
4
4
|
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../src/eip-712/sign.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../src/eip-712/sign.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EACL,KAAK,iBAAiB,EAAE,KAAK,sBAAsB,EACpD,MAAM,qBAAqB,CAAA;AAE5B,eAAO,MAAM,iBAAiB,GAAU,QAAQ,MAAM,EAAE,MAAM,iBAAiB,KAAG,OAAO,CAAC,sBAAsB,CAU/G,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EIP712DataPayload } from '../Payloads/index.ts';
|
|
2
2
|
export declare const wallet: import("ethers/wallet").HDNodeWallet;
|
|
3
|
-
export declare const samplePayload:
|
|
3
|
+
export declare const samplePayload: EIP712DataPayload;
|
|
4
4
|
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/eip-712/spec/fixtures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/eip-712/spec/fixtures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAK7D,eAAO,MAAM,MAAM,sCAA8B,CAAA;AAEjD,eAAO,MAAM,aAAa,EAAE,iBAiB3B,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const verifyEIP712Message: (data: EIP712Payload, sig: EIP712SignaturePayload) => Promisable<boolean>;
|
|
1
|
+
import type { EIP712DataPayload, EIP712SignaturePayload } from './Payloads/index.ts';
|
|
2
|
+
export declare const verifyEIP712Message: (data: EIP712DataPayload, sig: EIP712SignaturePayload) => Promise<boolean>;
|
|
4
3
|
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/eip-712/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/eip-712/verify.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAEpF,eAAO,MAAM,mBAAmB,GAAU,MAAM,iBAAiB,EAAE,KAAK,sBAAsB,KAAG,OAAO,CAAC,OAAO,CAY/G,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -125,7 +125,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
125
125
|
let jumpHash = currentBlock.previous;
|
|
126
126
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
127
127
|
for (const [step, stepSize2] of StepSizes.entries()) {
|
|
128
|
-
const possibleJumpBlockNumber = currentBlock.block - stepSize2;
|
|
128
|
+
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize2 - 1;
|
|
129
129
|
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
130
130
|
jumpBlockNumber = possibleJumpBlockNumber;
|
|
131
131
|
jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`);
|
|
@@ -139,7 +139,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
if (currentBlock.block < blockNumber) {
|
|
142
|
-
throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${
|
|
142
|
+
throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${head}.`);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
return currentBlock;
|
|
@@ -704,27 +704,27 @@ var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
|
704
704
|
}, "hasMongoConfig");
|
|
705
705
|
var MongoConfigZod = z10.object({
|
|
706
706
|
// TODO: Create from other arguments
|
|
707
|
-
connectionString: z10.string().
|
|
707
|
+
connectionString: z10.string().nonempty().optional().register(globalRegistry9, {
|
|
708
708
|
description: "MongoDB connection string",
|
|
709
709
|
title: "storage.mongo.connectionString",
|
|
710
710
|
type: "string"
|
|
711
711
|
}),
|
|
712
|
-
database: z10.string().
|
|
712
|
+
database: z10.string().nonempty().optional().register(globalRegistry9, {
|
|
713
713
|
description: "MongoDB database name",
|
|
714
714
|
title: "storage.mongo.database",
|
|
715
715
|
type: "string"
|
|
716
716
|
}),
|
|
717
|
-
domain: z10.string().
|
|
717
|
+
domain: z10.string().nonempty().optional().register(globalRegistry9, {
|
|
718
718
|
description: "MongoDB domain",
|
|
719
719
|
title: "storage.mongo.domain",
|
|
720
720
|
type: "string"
|
|
721
721
|
}),
|
|
722
|
-
password: z10.string().
|
|
722
|
+
password: z10.string().nonempty().optional().register(globalRegistry9, {
|
|
723
723
|
description: "MongoDB password",
|
|
724
724
|
title: "storage.mongo.password",
|
|
725
725
|
type: "string"
|
|
726
726
|
}),
|
|
727
|
-
username: z10.string().
|
|
727
|
+
username: z10.string().nonempty().optional().register(globalRegistry9, {
|
|
728
728
|
description: "MongoDB username",
|
|
729
729
|
title: "storage.mongo.username",
|
|
730
730
|
type: "string"
|
|
@@ -846,29 +846,84 @@ __name(isUsageMeta, "isUsageMeta");
|
|
|
846
846
|
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH = 1760572800;
|
|
847
847
|
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK = 107496;
|
|
848
848
|
|
|
849
|
-
// src/eip-712/
|
|
850
|
-
|
|
851
|
-
|
|
849
|
+
// src/eip-712/Payloads/EIP712Data.ts
|
|
850
|
+
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
851
|
+
import { isPayloadOfZodType } from "@xyo-network/payload-model";
|
|
852
|
+
import z17 from "zod";
|
|
853
|
+
|
|
854
|
+
// src/eip-712/Types.ts
|
|
855
|
+
import z16 from "zod";
|
|
856
|
+
var TypedDataDomainZod = z16.object({
|
|
857
|
+
name: z16.string().nullable().optional(),
|
|
858
|
+
version: z16.string().nullable().optional(),
|
|
859
|
+
chainId: z16.union([
|
|
860
|
+
z16.string(),
|
|
861
|
+
z16.number(),
|
|
862
|
+
z16.bigint()
|
|
863
|
+
]).nullable().optional(),
|
|
864
|
+
verifyingContract: z16.string().nullable().optional(),
|
|
865
|
+
salt: z16.union([
|
|
866
|
+
z16.string(),
|
|
867
|
+
z16.instanceof(Uint8Array)
|
|
868
|
+
]).nullable().optional()
|
|
869
|
+
});
|
|
870
|
+
var TypedDataFieldZod = z16.object({
|
|
871
|
+
name: z16.string(),
|
|
872
|
+
type: z16.string()
|
|
873
|
+
});
|
|
874
|
+
var TypedDataTypesZod = z16.record(z16.string(), z16.array(TypedDataFieldZod));
|
|
875
|
+
var TypedDataValueZod = z16.record(z16.string(), z16.any());
|
|
876
|
+
|
|
877
|
+
// src/eip-712/Payloads/EIP712Data.ts
|
|
878
|
+
var EIP712DataPayloadFieldsZod = z17.object({
|
|
879
|
+
domain: TypedDataDomainZod,
|
|
880
|
+
types: TypedDataTypesZod,
|
|
881
|
+
values: TypedDataValueZod
|
|
882
|
+
});
|
|
883
|
+
var EIP712DataPayloadSchema = "network.xyo.chains.ethereum.eip712.data";
|
|
884
|
+
var EIP712PayloadSchema = EIP712DataPayloadSchema;
|
|
885
|
+
var isEIP712DataPayload = isPayloadOfZodType(EIP712DataPayloadFieldsZod, EIP712DataPayloadSchema);
|
|
886
|
+
var asEIP712DataPayload = AsObjectFactory4.create(isEIP712DataPayload);
|
|
887
|
+
|
|
888
|
+
// src/eip-712/Payloads/EIP712Signature.ts
|
|
889
|
+
import { HashZod } from "@xylabs/hex";
|
|
890
|
+
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
891
|
+
import { isPayloadOfZodType as isPayloadOfZodType2 } from "@xyo-network/payload-model";
|
|
892
|
+
import z18 from "zod";
|
|
893
|
+
var EIP712SignaturePayloadFieldsZod = z18.object({
|
|
894
|
+
address: z18.string(),
|
|
895
|
+
hash: HashZod,
|
|
896
|
+
signature: z18.string()
|
|
897
|
+
});
|
|
898
|
+
var EIP712SignaturePayloadSchema = "network.xyo.chains.ethereum.eip712.signature";
|
|
899
|
+
var isEIP712SignaturePayload = isPayloadOfZodType2(EIP712SignaturePayloadFieldsZod, EIP712SignaturePayloadSchema);
|
|
900
|
+
var asEIP712SignaturePayload = AsObjectFactory5.create(isEIP712SignaturePayload);
|
|
852
901
|
|
|
853
902
|
// src/eip-712/sign.ts
|
|
854
903
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
855
904
|
var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
856
|
-
const {
|
|
857
|
-
const signature = await signer.signTypedData(
|
|
905
|
+
const { domain, types, values } = data;
|
|
906
|
+
const signature = await signer.signTypedData(domain, types, values);
|
|
858
907
|
const hash = await PayloadBuilder2.hash(data);
|
|
908
|
+
const address = await signer.getAddress();
|
|
859
909
|
return {
|
|
860
|
-
address
|
|
861
|
-
|
|
910
|
+
address,
|
|
911
|
+
hash,
|
|
862
912
|
schema: EIP712SignaturePayloadSchema,
|
|
863
|
-
|
|
913
|
+
signature
|
|
864
914
|
};
|
|
865
915
|
}, "signEIP712Message");
|
|
866
916
|
|
|
867
917
|
// src/eip-712/verify.ts
|
|
918
|
+
import { asHash as asHash2 } from "@xylabs/hex";
|
|
919
|
+
import { isUndefined as isUndefined2 } from "@xylabs/typeof";
|
|
920
|
+
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
868
921
|
import { verifyTypedData } from "ethers/hash";
|
|
869
|
-
var verifyEIP712Message = /* @__PURE__ */ __name((data, sig) => {
|
|
870
|
-
const { address, signature } = sig;
|
|
922
|
+
var verifyEIP712Message = /* @__PURE__ */ __name(async (data, sig) => {
|
|
923
|
+
const { address, signature, hash } = sig;
|
|
871
924
|
const { schema, ...fields } = data;
|
|
925
|
+
const signedHash = asHash2(hash);
|
|
926
|
+
if (isUndefined2(signedHash) || signedHash !== await PayloadBuilder3.hash(data)) return false;
|
|
872
927
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
873
928
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
874
929
|
}, "verifyEIP712Message");
|
|
@@ -978,7 +1033,7 @@ __name(stepTransferIndex, "stepTransferIndex");
|
|
|
978
1033
|
|
|
979
1034
|
// src/primitives/summary/balances/balancesStepSummaryFromRange.ts
|
|
980
1035
|
import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
981
|
-
import { PayloadBuilder as
|
|
1036
|
+
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
982
1037
|
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
983
1038
|
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol";
|
|
984
1039
|
async function balancesStepSummaryFromRange(context, range) {
|
|
@@ -1033,7 +1088,7 @@ async function balancesStepSummaryFromRange(context, range) {
|
|
|
1033
1088
|
}
|
|
1034
1089
|
}
|
|
1035
1090
|
}
|
|
1036
|
-
const finalResult = await
|
|
1091
|
+
const finalResult = await PayloadBuilder4.addStorageMeta(result);
|
|
1037
1092
|
return finalResult;
|
|
1038
1093
|
}
|
|
1039
1094
|
__name(balancesStepSummaryFromRange, "balancesStepSummaryFromRange");
|
|
@@ -1107,7 +1162,7 @@ __name(xl1BlockNumberToEthBlockNumber, "xl1BlockNumberToEthBlockNumber");
|
|
|
1107
1162
|
import { assertEx as assertEx8 } from "@xylabs/assert";
|
|
1108
1163
|
import { toHex as toHex2 } from "@xylabs/hex";
|
|
1109
1164
|
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
1110
|
-
import { PayloadBuilder as
|
|
1165
|
+
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1111
1166
|
import { defaultTransactionFees } from "@xyo-network/xl1-protocol";
|
|
1112
1167
|
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
1113
1168
|
if (from === void 0 && Array.isArray(signer)) {
|
|
@@ -1124,7 +1179,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
1124
1179
|
nbf,
|
|
1125
1180
|
exp
|
|
1126
1181
|
};
|
|
1127
|
-
const elevatedHashes = await
|
|
1182
|
+
const elevatedHashes = await PayloadBuilder5.hashes(onChainPayloads);
|
|
1128
1183
|
const script = [];
|
|
1129
1184
|
for (const elevatedHash of elevatedHashes) {
|
|
1130
1185
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -1145,8 +1200,8 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
1145
1200
|
signer
|
|
1146
1201
|
]).build();
|
|
1147
1202
|
return [
|
|
1148
|
-
await
|
|
1149
|
-
await
|
|
1203
|
+
await PayloadBuilder5.addStorageMeta(tx),
|
|
1204
|
+
await PayloadBuilder5.addStorageMeta(txPayloads)
|
|
1150
1205
|
];
|
|
1151
1206
|
}
|
|
1152
1207
|
__name(buildTransaction, "buildTransaction");
|
|
@@ -1154,7 +1209,7 @@ __name(buildTransaction, "buildTransaction");
|
|
|
1154
1209
|
// src/transaction/buildUnsignedTransaction.ts
|
|
1155
1210
|
import { toHex as toHex3 } from "@xylabs/hex";
|
|
1156
1211
|
import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundwitness-builder";
|
|
1157
|
-
import { PayloadBuilder as
|
|
1212
|
+
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
1158
1213
|
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol";
|
|
1159
1214
|
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
1160
1215
|
const txBoundWitnessFields = {
|
|
@@ -1168,7 +1223,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
1168
1223
|
nbf,
|
|
1169
1224
|
exp
|
|
1170
1225
|
};
|
|
1171
|
-
const elevatedHashes = await
|
|
1226
|
+
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
1172
1227
|
const script = [];
|
|
1173
1228
|
for (const elevatedHash of elevatedHashes) {
|
|
1174
1229
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -1187,8 +1242,8 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
1187
1242
|
...offChainPayloads
|
|
1188
1243
|
]).build();
|
|
1189
1244
|
return [
|
|
1190
|
-
await
|
|
1191
|
-
await
|
|
1245
|
+
await PayloadBuilder6.addStorageMeta(tx),
|
|
1246
|
+
await PayloadBuilder6.addStorageMeta(txPayloads)
|
|
1192
1247
|
];
|
|
1193
1248
|
}
|
|
1194
1249
|
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
@@ -1196,12 +1251,12 @@ __name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
|
1196
1251
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
1197
1252
|
import { delay } from "@xylabs/delay";
|
|
1198
1253
|
import { isDefined as isDefined6 } from "@xylabs/typeof";
|
|
1199
|
-
import { PayloadBuilder as
|
|
1254
|
+
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1200
1255
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
1201
1256
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
1202
1257
|
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, transaction, options) => {
|
|
1203
1258
|
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {};
|
|
1204
|
-
const txBWHash = await
|
|
1259
|
+
const txBWHash = await PayloadBuilder7.hash(transaction);
|
|
1205
1260
|
options?.logger?.log("\u{1F680} confirming transaction:", txBWHash, "\n");
|
|
1206
1261
|
let attempts = 0;
|
|
1207
1262
|
while (true) {
|
|
@@ -1286,17 +1341,17 @@ var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) =>
|
|
|
1286
1341
|
}, "hydrateElevatedTransaction");
|
|
1287
1342
|
|
|
1288
1343
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
1289
|
-
import { PayloadBuilder as
|
|
1344
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
1290
1345
|
function transactionBlockByteCount([transaction, payloads]) {
|
|
1291
|
-
const cleanTransaction =
|
|
1346
|
+
const cleanTransaction = PayloadBuilder8.omitStorageMeta(transaction);
|
|
1292
1347
|
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
1293
|
-
const cleanPayloads =
|
|
1348
|
+
const cleanPayloads = PayloadBuilder8.omitStorageMeta(payloads);
|
|
1294
1349
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
1295
1350
|
}
|
|
1296
1351
|
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
1297
1352
|
|
|
1298
1353
|
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
1299
|
-
import { asHash as
|
|
1354
|
+
import { asHash as asHash3 } from "@xylabs/hex";
|
|
1300
1355
|
|
|
1301
1356
|
// src/transaction/primitives/transactionOperations.ts
|
|
1302
1357
|
function crackOperation(operation) {
|
|
@@ -1318,7 +1373,7 @@ __name(crackOperations, "crackOperations");
|
|
|
1318
1373
|
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
1319
1374
|
function transactionElevatedPayloadHashes(transaction) {
|
|
1320
1375
|
const elevateOperations = crackOperations(transaction.script ?? []).filter((op) => op[0] === "elevate");
|
|
1321
|
-
return elevateOperations.map((op) =>
|
|
1376
|
+
return elevateOperations.map((op) => asHash3(op[1][0], true));
|
|
1322
1377
|
}
|
|
1323
1378
|
__name(transactionElevatedPayloadHashes, "transactionElevatedPayloadHashes");
|
|
1324
1379
|
function transactionElevatedPayloads([transaction, payloads]) {
|
|
@@ -1349,15 +1404,15 @@ __name(transactionRequiredGas, "transactionRequiredGas");
|
|
|
1349
1404
|
// src/transaction/script.ts
|
|
1350
1405
|
import { filterAs as filterAs2 } from "@xylabs/array";
|
|
1351
1406
|
import { assertEx as assertEx10 } from "@xylabs/assert";
|
|
1352
|
-
import { asHash as
|
|
1407
|
+
import { asHash as asHash4 } from "@xylabs/hex";
|
|
1353
1408
|
import { isAllowedBlockPayloadWithHashStorageMeta } from "@xyo-network/xl1-protocol";
|
|
1354
1409
|
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
1355
1410
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
1356
|
-
return filterAs2(hashes, (h) =>
|
|
1411
|
+
return filterAs2(hashes, (h) => asHash4(h));
|
|
1357
1412
|
}, "tryExtractElevatedHashesFromScript");
|
|
1358
1413
|
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
1359
1414
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
1360
|
-
const filtered = filterAs2(hashes, (h) =>
|
|
1415
|
+
const filtered = filterAs2(hashes, (h) => asHash4(h));
|
|
1361
1416
|
assertEx10(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
1362
1417
|
return filtered;
|
|
1363
1418
|
}, "extractElevatedHashesFromScript");
|
|
@@ -1380,7 +1435,7 @@ var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
|
1380
1435
|
import { toArrayBuffer } from "@xylabs/arraybuffer";
|
|
1381
1436
|
import { assertEx as assertEx11 } from "@xylabs/assert";
|
|
1382
1437
|
import { hexFromArrayBuffer } from "@xylabs/hex";
|
|
1383
|
-
import { PayloadBuilder as
|
|
1438
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
1384
1439
|
async function signTransaction(tx, account) {
|
|
1385
1440
|
assertEx11(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
1386
1441
|
const signedTx = structuredClone(tx);
|
|
@@ -1390,7 +1445,7 @@ async function signTransaction(tx, account) {
|
|
|
1390
1445
|
signedTx.previous_hashes = [
|
|
1391
1446
|
account.previousHash ?? null
|
|
1392
1447
|
];
|
|
1393
|
-
const hash = await
|
|
1448
|
+
const hash = await PayloadBuilder9.dataHash(signedTx);
|
|
1394
1449
|
const hashBytes = toArrayBuffer(hash);
|
|
1395
1450
|
const [signature] = await account.sign(hashBytes);
|
|
1396
1451
|
signedTx.$signatures = [
|
|
@@ -1436,7 +1491,10 @@ export {
|
|
|
1436
1491
|
COIN_TYPES,
|
|
1437
1492
|
ConfigZod,
|
|
1438
1493
|
DEFAULT_WALLET_PATH,
|
|
1494
|
+
EIP712DataPayloadFieldsZod,
|
|
1495
|
+
EIP712DataPayloadSchema,
|
|
1439
1496
|
EIP712PayloadSchema,
|
|
1497
|
+
EIP712SignaturePayloadFieldsZod,
|
|
1440
1498
|
EIP712SignaturePayloadSchema,
|
|
1441
1499
|
GlobalMetaSchema,
|
|
1442
1500
|
JSONSchemaMetaSchema,
|
|
@@ -1446,6 +1504,10 @@ export {
|
|
|
1446
1504
|
StepSummarySchema,
|
|
1447
1505
|
TODO,
|
|
1448
1506
|
TransfersStepSummarySchema,
|
|
1507
|
+
TypedDataDomainZod,
|
|
1508
|
+
TypedDataFieldZod,
|
|
1509
|
+
TypedDataTypesZod,
|
|
1510
|
+
TypedDataValueZod,
|
|
1449
1511
|
UsageMetaSchema,
|
|
1450
1512
|
WALLET_COMPLIANCE,
|
|
1451
1513
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH,
|
|
@@ -1458,6 +1520,8 @@ export {
|
|
|
1458
1520
|
asAddressPairPayload,
|
|
1459
1521
|
asBalancesStepSummary,
|
|
1460
1522
|
asBalancesStepSummaryWithStorageMeta,
|
|
1523
|
+
asEIP712DataPayload,
|
|
1524
|
+
asEIP712SignaturePayload,
|
|
1461
1525
|
asOptionalAddressPairPayload,
|
|
1462
1526
|
asTransfersStepSummary,
|
|
1463
1527
|
asTransfersStepSummaryWithStorageMeta,
|
|
@@ -1492,6 +1556,8 @@ export {
|
|
|
1492
1556
|
isAddressPairPayload,
|
|
1493
1557
|
isBalancesStepSummary,
|
|
1494
1558
|
isBalancesStepSummaryWithStorageMeta,
|
|
1559
|
+
isEIP712DataPayload,
|
|
1560
|
+
isEIP712SignaturePayload,
|
|
1495
1561
|
isLocalhost,
|
|
1496
1562
|
isNegativeBigInt,
|
|
1497
1563
|
isPositiveBigInt,
|