@xyo-network/xl1-rpc 1.7.17 → 1.7.18
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/index.mjs +45 -15
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/provider/provider/confirmSubmittedTransaction.d.ts +21 -0
- package/dist/neutral/provider/provider/confirmSubmittedTransaction.d.ts.map +1 -0
- package/dist/neutral/provider/provider/index.d.ts +1 -0
- package/dist/neutral/provider/provider/index.d.ts.map +1 -1
- package/dist/neutral/types/schema/common/JsonSchema.d.ts +7 -0
- package/dist/neutral/types/schema/common/JsonSchema.d.ts.map +1 -0
- package/dist/neutral/types/schema/common/index.d.ts +1 -0
- package/dist/neutral/types/schema/common/index.d.ts.map +1 -1
- package/dist/node/index-node.mjs +45 -15
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/provider/provider/confirmSubmittedTransaction.d.ts +21 -0
- package/dist/node/provider/provider/confirmSubmittedTransaction.d.ts.map +1 -0
- package/dist/node/provider/provider/index.d.ts +1 -0
- package/dist/node/provider/provider/index.d.ts.map +1 -1
- package/dist/node/types/schema/common/JsonSchema.d.ts +7 -0
- package/dist/node/types/schema/common/JsonSchema.d.ts.map +1 -0
- package/dist/node/types/schema/common/index.d.ts +1 -0
- package/dist/node/types/schema/common/index.d.ts.map +1 -1
- package/package.json +36 -35
- package/src/provider/provider/confirmSubmittedTransaction.ts +55 -0
- package/src/provider/provider/index.ts +1 -0
- package/src/types/schema/common/JsonSchema.ts +19 -0
- package/src/types/schema/common/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/provider/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/provider/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const JsonValueSchema: z.ZodType<unknown>;
|
|
3
|
+
export declare const JsonObjectSchema: z.ZodRecord<z.ZodString, z.ZodType<unknown, z.ZodTypeDef, unknown>>;
|
|
4
|
+
export type JsonValue = z.infer<typeof JsonValueSchema>;
|
|
5
|
+
export type JsonObject = z.infer<typeof JsonObjectSchema>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=JsonSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchema.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/JsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,QAAA,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAQnC,CAAA;AAGL,eAAO,MAAM,gBAAgB,qEAA4B,CAAA;AAGzD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -6,6 +6,7 @@ export * from './HashSchema.ts';
|
|
|
6
6
|
export * from './HexSchema.ts';
|
|
7
7
|
export * from './HydratedBlockSchema.ts';
|
|
8
8
|
export * from './HydratedTransactionSchema.ts';
|
|
9
|
+
export * from './JsonSchema.ts';
|
|
9
10
|
export * from './PayloadSchema.ts';
|
|
10
11
|
export * from './SequenceSchema.ts';
|
|
11
12
|
export * from './StorageMetaSchema.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oCAAoC,CAAA;AAClD,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/schema/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oCAAoC,CAAA;AAClD,cAAc,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-rpc",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.18",
|
|
5
5
|
"description": "XYO Layer One API",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -57,42 +57,43 @@
|
|
|
57
57
|
"types": "tsc --noEmit -p tsconfig.test.json"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@metamask/json-rpc-engine": "
|
|
61
|
-
"@metamask/utils": "
|
|
62
|
-
"@xylabs/assert": "
|
|
63
|
-
"@xylabs/axios": "
|
|
64
|
-
"@xylabs/delay": "
|
|
65
|
-
"@xylabs/hex": "
|
|
66
|
-
"@xylabs/object": "
|
|
67
|
-
"@xylabs/promise": "
|
|
68
|
-
"@xylabs/typeof": "
|
|
69
|
-
"@xyo-network/account-model": "
|
|
70
|
-
"@xyo-network/archivist-memory": "
|
|
71
|
-
"@xyo-network/archivist-model": "
|
|
72
|
-
"@xyo-network/boundwitness-model": "
|
|
73
|
-
"@xyo-network/module-model": "
|
|
74
|
-
"@xyo-network/node-model": "
|
|
75
|
-
"@xyo-network/payload-builder": "
|
|
76
|
-
"@xyo-network/payload-model": "
|
|
77
|
-
"@xyo-network/payload-wrapper": "
|
|
78
|
-
"@xyo-network/xl1-protocol": "
|
|
79
|
-
"@xyo-network/xl1-protocol-sdk": "
|
|
80
|
-
"@xyo-network/xl1-wrappers": "
|
|
81
|
-
"axios": "
|
|
82
|
-
"uuid": "
|
|
83
|
-
"zod": "
|
|
60
|
+
"@metamask/json-rpc-engine": "~10.0.3",
|
|
61
|
+
"@metamask/utils": "~11.4.2",
|
|
62
|
+
"@xylabs/assert": "~4.13.23",
|
|
63
|
+
"@xylabs/axios": "~4.13.23",
|
|
64
|
+
"@xylabs/delay": "~4.13.23",
|
|
65
|
+
"@xylabs/hex": "~4.13.23",
|
|
66
|
+
"@xylabs/object": "~4.13.23",
|
|
67
|
+
"@xylabs/promise": "~4.13.23",
|
|
68
|
+
"@xylabs/typeof": "~4.13.23",
|
|
69
|
+
"@xyo-network/account-model": "~4.1.7",
|
|
70
|
+
"@xyo-network/archivist-memory": "~4.1.7",
|
|
71
|
+
"@xyo-network/archivist-model": "~4.1.7",
|
|
72
|
+
"@xyo-network/boundwitness-model": "~4.1.7",
|
|
73
|
+
"@xyo-network/module-model": "~4.1.7",
|
|
74
|
+
"@xyo-network/node-model": "~4.1.7",
|
|
75
|
+
"@xyo-network/payload-builder": "~4.1.7",
|
|
76
|
+
"@xyo-network/payload-model": "~4.1.7",
|
|
77
|
+
"@xyo-network/payload-wrapper": "~4.1.7",
|
|
78
|
+
"@xyo-network/xl1-protocol": "~1.7.20",
|
|
79
|
+
"@xyo-network/xl1-protocol-sdk": "~1.7.18",
|
|
80
|
+
"@xyo-network/xl1-wrappers": "~1.7.18",
|
|
81
|
+
"axios": "~1.11.0",
|
|
82
|
+
"uuid": "~11.1.0",
|
|
83
|
+
"zod": "~3.25.76"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@metamask/utils": "
|
|
87
|
-
"@types/node": "
|
|
88
|
-
"@xylabs/ts-scripts-yarn3": "
|
|
89
|
-
"@xylabs/tsconfig": "
|
|
90
|
-
"@xylabs/vitest-extended": "
|
|
91
|
-
"@xyo-network/account": "
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
86
|
+
"@metamask/utils": "~11.4.2",
|
|
87
|
+
"@types/node": "~24.1.0",
|
|
88
|
+
"@xylabs/ts-scripts-yarn3": "~7.0.1",
|
|
89
|
+
"@xylabs/tsconfig": "~7.0.1",
|
|
90
|
+
"@xylabs/vitest-extended": "~4.13.23",
|
|
91
|
+
"@xyo-network/account": "~4.1.7",
|
|
92
|
+
"@xyo-network/wallet": "~4.1.7",
|
|
93
|
+
"dotenv": "~17.2.1",
|
|
94
|
+
"knip": "~5.62.0",
|
|
95
|
+
"typescript": "~5.8.3",
|
|
96
|
+
"vitest": "~3.2.4"
|
|
96
97
|
},
|
|
97
98
|
"packageManager": "yarn@4.6.0",
|
|
98
99
|
"engines": {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { delay } from '@xylabs/delay'
|
|
2
|
+
import type { Logger } from '@xylabs/logger'
|
|
3
|
+
import { isDefined } from '@xylabs/typeof'
|
|
4
|
+
import type { Signed } from '@xyo-network/boundwitness-model'
|
|
5
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
6
|
+
import type {
|
|
7
|
+
HydratedTransaction, TransactionBoundWitness, XyoConnectionProvider,
|
|
8
|
+
} from '@xyo-network/xl1-protocol'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_CONFIRMATION_ATTEMPTS = 20
|
|
11
|
+
const DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1000 // milliseconds
|
|
12
|
+
|
|
13
|
+
export type ConfirmSubmittedTransactionOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Number of attempts to confirm the transaction.
|
|
16
|
+
* Defaults to 20.
|
|
17
|
+
*/
|
|
18
|
+
attempts?: number
|
|
19
|
+
/**
|
|
20
|
+
* Delay in milliseconds between confirmation attempts.
|
|
21
|
+
* Defaults to 1000 (1 second).
|
|
22
|
+
*/
|
|
23
|
+
delay?: number
|
|
24
|
+
/**
|
|
25
|
+
* Optional logger instance for logging progress.
|
|
26
|
+
*/
|
|
27
|
+
logger?: Logger
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const confirmSubmittedTransaction = async (
|
|
31
|
+
provider: XyoConnectionProvider,
|
|
32
|
+
txBW: Signed<TransactionBoundWitness>,
|
|
33
|
+
options?: ConfirmSubmittedTransactionOptions,
|
|
34
|
+
): Promise<HydratedTransaction> => {
|
|
35
|
+
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {}
|
|
36
|
+
const txBWHash = await PayloadBuilder.hash(txBW)
|
|
37
|
+
options?.logger?.log('✅ confirming transaction:', txBWHash, '\n')
|
|
38
|
+
let attempts = 0
|
|
39
|
+
while (true) {
|
|
40
|
+
const tx = await provider.viewer?.transactionByHash(txBWHash) ?? undefined
|
|
41
|
+
if (isDefined(tx)) {
|
|
42
|
+
options?.logger?.log('🍻 Transaction confirmed:', txBWHash, '\n')
|
|
43
|
+
return tx
|
|
44
|
+
} else {
|
|
45
|
+
attempts++
|
|
46
|
+
if (attempts > maxAttempts) {
|
|
47
|
+
options?.logger?.error(`⚠️ Transaction not confirmed after ${maxAttempts} attempts`)
|
|
48
|
+
throw new Error(`Transaction ${txBWHash} not confirmed after ${maxAttempts} attempts`)
|
|
49
|
+
} else {
|
|
50
|
+
options?.logger?.log(`🔄 Transaction not confirmed yet, attempt ${attempts}. Retrying...`, '\n')
|
|
51
|
+
await delay(attemptDelay)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
// Define recursive JSON value schema
|
|
4
|
+
const JsonValueSchema: z.ZodType<unknown> = z.lazy(() =>
|
|
5
|
+
z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number(),
|
|
8
|
+
z.boolean(),
|
|
9
|
+
z.null(),
|
|
10
|
+
z.array(JsonValueSchema),
|
|
11
|
+
z.record(JsonValueSchema), // object with string keys and JSON values
|
|
12
|
+
]))
|
|
13
|
+
|
|
14
|
+
// JSON object schema — top-level must be an object
|
|
15
|
+
export const JsonObjectSchema = z.record(JsonValueSchema)
|
|
16
|
+
|
|
17
|
+
// TypeScript type for reference
|
|
18
|
+
export type JsonValue = z.infer<typeof JsonValueSchema>
|
|
19
|
+
export type JsonObject = z.infer<typeof JsonObjectSchema>
|
|
@@ -6,6 +6,7 @@ export * from './HashSchema.ts'
|
|
|
6
6
|
export * from './HexSchema.ts'
|
|
7
7
|
export * from './HydratedBlockSchema.ts'
|
|
8
8
|
export * from './HydratedTransactionSchema.ts'
|
|
9
|
+
export * from './JsonSchema.ts'
|
|
9
10
|
export * from './PayloadSchema.ts'
|
|
10
11
|
export * from './SequenceSchema.ts'
|
|
11
12
|
export * from './StorageMetaSchema.ts'
|