@sovereign-sdk/web3 0.0.3 → 0.0.4
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/{rollup.d.ts → index.d.mts} +25 -8
- package/dist/index.d.ts +54 -5
- package/dist/index.js +217 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +182 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +7 -4
- package/dist/errors.d.ts +0 -4
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -15
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -5
- package/dist/index.test.js.map +0 -1
- package/dist/rollup.d.ts.map +0 -1
- package/dist/rollup.js +0 -67
- package/dist/rollup.js.map +0 -1
- package/dist/serialization.d.ts +0 -9
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -33
- package/dist/serialization.js.map +0 -1
- package/dist/signer.d.ts +0 -5
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -2
- package/dist/signer.js.map +0 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -22
- package/dist/utils.js.map +0 -1
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import SovereignClient from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import SovereignClient from '@sovereign-sdk/client';
|
|
2
|
+
|
|
3
|
+
interface Signer {
|
|
4
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
5
|
+
publicKey(): Promise<Uint8Array>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type RollupSchema = object;
|
|
9
|
+
type RollupSerializer = {
|
|
10
|
+
serialize(input: unknown, index: number): Uint8Array;
|
|
11
|
+
serializeRuntimeCall(input: unknown): Uint8Array;
|
|
12
|
+
serializeUnsignedTx(input: unknown): Uint8Array;
|
|
13
|
+
serializeTx(input: unknown): Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
declare function createSerializer(schemaObject: RollupSchema): RollupSerializer;
|
|
16
|
+
|
|
17
|
+
type RollupCallResult = {
|
|
5
18
|
response: SovereignClient.Sequencer.TxCreateResponse;
|
|
6
19
|
unsignedTx: unknown;
|
|
7
20
|
};
|
|
8
|
-
|
|
21
|
+
type RollupConfig = {
|
|
9
22
|
url?: string;
|
|
10
23
|
schema: RollupSchema;
|
|
11
24
|
defaultTxDetails: TxDetails;
|
|
@@ -22,7 +35,7 @@ type SignerParams = {
|
|
|
22
35
|
type CallParams = {
|
|
23
36
|
txDetails?: TxDetails;
|
|
24
37
|
} & SignerParams;
|
|
25
|
-
|
|
38
|
+
declare class StandardRollup<Tx = unknown, UnsignedTx = unknown> {
|
|
26
39
|
private readonly _config;
|
|
27
40
|
private readonly _client;
|
|
28
41
|
private readonly _serializer;
|
|
@@ -33,5 +46,9 @@ export declare class StandardRollup<Tx = unknown, UnsignedTx = unknown> {
|
|
|
33
46
|
get client(): SovereignClient;
|
|
34
47
|
get serializer(): RollupSerializer;
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
|
|
50
|
+
declare class SovereignError extends Error {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { type RollupCallResult, type RollupConfig, type RollupSchema, type RollupSerializer, type Signer, SovereignError, StandardRollup, createSerializer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import SovereignClient from '@sovereign-sdk/client';
|
|
2
|
+
|
|
3
|
+
interface Signer {
|
|
4
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
5
|
+
publicKey(): Promise<Uint8Array>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type RollupSchema = object;
|
|
9
|
+
type RollupSerializer = {
|
|
10
|
+
serialize(input: unknown, index: number): Uint8Array;
|
|
11
|
+
serializeRuntimeCall(input: unknown): Uint8Array;
|
|
12
|
+
serializeUnsignedTx(input: unknown): Uint8Array;
|
|
13
|
+
serializeTx(input: unknown): Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
declare function createSerializer(schemaObject: RollupSchema): RollupSerializer;
|
|
16
|
+
|
|
17
|
+
type RollupCallResult = {
|
|
18
|
+
response: SovereignClient.Sequencer.TxCreateResponse;
|
|
19
|
+
unsignedTx: unknown;
|
|
20
|
+
};
|
|
21
|
+
type RollupConfig = {
|
|
22
|
+
url?: string;
|
|
23
|
+
schema: RollupSchema;
|
|
24
|
+
defaultTxDetails: TxDetails;
|
|
25
|
+
};
|
|
26
|
+
type TxDetails = {
|
|
27
|
+
max_priority_fee_bips: number;
|
|
28
|
+
max_fee: bigint;
|
|
29
|
+
gas_limit?: bigint;
|
|
30
|
+
chain_id: bigint;
|
|
31
|
+
};
|
|
32
|
+
type SignerParams = {
|
|
33
|
+
signer: Signer;
|
|
34
|
+
};
|
|
35
|
+
type CallParams = {
|
|
36
|
+
txDetails?: TxDetails;
|
|
37
|
+
} & SignerParams;
|
|
38
|
+
declare class StandardRollup<Tx = unknown, UnsignedTx = unknown> {
|
|
39
|
+
private readonly _config;
|
|
40
|
+
private readonly _client;
|
|
41
|
+
private readonly _serializer;
|
|
42
|
+
constructor(config: RollupConfig);
|
|
43
|
+
submitTransaction(transaction: Tx): Promise<SovereignClient.Sequencer.TxCreateResponse>;
|
|
44
|
+
signAndSubmitTransaction(unsignedTx: UnsignedTx, { signer }: SignerParams): Promise<SovereignClient.Sequencer.TxCreateResponse>;
|
|
45
|
+
call(runtimeMessage: unknown, { signer, txDetails }: CallParams): Promise<RollupCallResult>;
|
|
46
|
+
get client(): SovereignClient;
|
|
47
|
+
get serializer(): RollupSerializer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class SovereignError extends Error {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { type RollupCallResult, type RollupConfig, type RollupSchema, type RollupSerializer, type Signer, SovereignError, StandardRollup, createSerializer };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
+
var __async = (__this, __arguments, generator) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
var fulfilled = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.next(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var rejected = (value) => {
|
|
53
|
+
try {
|
|
54
|
+
step(generator.throw(value));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
60
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/index.ts
|
|
65
|
+
var src_exports = {};
|
|
66
|
+
__export(src_exports, {
|
|
67
|
+
SovereignError: () => SovereignError,
|
|
68
|
+
StandardRollup: () => StandardRollup,
|
|
69
|
+
createSerializer: () => createSerializer
|
|
70
|
+
});
|
|
71
|
+
module.exports = __toCommonJS(src_exports);
|
|
72
|
+
|
|
73
|
+
// src/rollup.ts
|
|
74
|
+
var import_client = __toESM(require("@sovereign-sdk/client"));
|
|
75
|
+
var import_js_base64 = require("js-base64");
|
|
76
|
+
|
|
77
|
+
// src/serialization.ts
|
|
78
|
+
var import_universal_wallet_wasm = require("@sovereign-sdk/universal-wallet-wasm");
|
|
79
|
+
|
|
80
|
+
// src/errors.ts
|
|
81
|
+
var SovereignError = class extends Error {
|
|
82
|
+
constructor(message) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = this.constructor.name;
|
|
85
|
+
this.stack = new Error().stack;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/serialization.ts
|
|
90
|
+
function loadSchema(schemaObject) {
|
|
91
|
+
try {
|
|
92
|
+
return import_universal_wallet_wasm.Schema.fromJSON(JSON.stringify(schemaObject));
|
|
93
|
+
} catch (err) {
|
|
94
|
+
throw new SovereignError(`Failed to create runtime schema due to: ${err}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function createSerializer(schemaObject) {
|
|
98
|
+
const schema = loadSchema(schemaObject);
|
|
99
|
+
return {
|
|
100
|
+
serialize(input, index) {
|
|
101
|
+
try {
|
|
102
|
+
return schema.jsonToBorsh(
|
|
103
|
+
index,
|
|
104
|
+
JSON.stringify(input, (_, value) => {
|
|
105
|
+
if (value instanceof Uint8Array) {
|
|
106
|
+
return Array.from(value);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw new SovereignError(`Failed to serialize input due to: ${err}`);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
serializeRuntimeCall(input) {
|
|
116
|
+
return this.serialize(
|
|
117
|
+
input,
|
|
118
|
+
schema.knownTypeIndex(import_universal_wallet_wasm.KnownTypeId.RuntimeCall)
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
serializeUnsignedTx(input) {
|
|
122
|
+
return this.serialize(
|
|
123
|
+
input,
|
|
124
|
+
schema.knownTypeIndex(import_universal_wallet_wasm.KnownTypeId.UnsignedTransaction)
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
serializeTx(input) {
|
|
128
|
+
return this.serialize(
|
|
129
|
+
input,
|
|
130
|
+
schema.knownTypeIndex(import_universal_wallet_wasm.KnownTypeId.Transaction)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/utils.ts
|
|
137
|
+
function bytesToHex(arr) {
|
|
138
|
+
let hex = "";
|
|
139
|
+
for (let i = 0; i < arr.length; i++) {
|
|
140
|
+
let hexValue = arr[i].toString(16);
|
|
141
|
+
if (hexValue.length === 1) {
|
|
142
|
+
hexValue = `0${hexValue}`;
|
|
143
|
+
}
|
|
144
|
+
hex += hexValue;
|
|
145
|
+
}
|
|
146
|
+
return hex;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/rollup.ts
|
|
150
|
+
var StandardRollup = class {
|
|
151
|
+
constructor(config) {
|
|
152
|
+
this._client = new import_client.default({ baseURL: config.url });
|
|
153
|
+
this._serializer = createSerializer(config.schema);
|
|
154
|
+
this._config = config;
|
|
155
|
+
}
|
|
156
|
+
submitTransaction(transaction) {
|
|
157
|
+
return __async(this, null, function* () {
|
|
158
|
+
const serializedTx = this.serializer.serializeTx(transaction);
|
|
159
|
+
return this.client.sequencer.txs.create({
|
|
160
|
+
body: import_js_base64.Base64.fromUint8Array(serializedTx)
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
signAndSubmitTransaction(_0, _1) {
|
|
165
|
+
return __async(this, arguments, function* (unsignedTx, { signer }) {
|
|
166
|
+
const serializedUnsignedTx = this.serializer.serializeUnsignedTx(unsignedTx);
|
|
167
|
+
const signature = yield signer.sign(serializedUnsignedTx);
|
|
168
|
+
const publicKey = yield signer.publicKey();
|
|
169
|
+
const tx = __spreadValues({
|
|
170
|
+
pub_key: {
|
|
171
|
+
pub_key: publicKey
|
|
172
|
+
},
|
|
173
|
+
signature: {
|
|
174
|
+
msg_sig: signature
|
|
175
|
+
}
|
|
176
|
+
}, unsignedTx);
|
|
177
|
+
return this.submitTransaction(tx);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
call(_0, _1) {
|
|
181
|
+
return __async(this, arguments, function* (runtimeMessage, { signer, txDetails }) {
|
|
182
|
+
const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
|
|
183
|
+
const publicKey = yield signer.publicKey();
|
|
184
|
+
const dedup = yield this.client.rollup.addresses.dedup.retrieve(
|
|
185
|
+
bytesToHex(publicKey)
|
|
186
|
+
);
|
|
187
|
+
const nonce = dedup.data.nonce;
|
|
188
|
+
const unsignedTx = {
|
|
189
|
+
runtime_msg: runtimeCall,
|
|
190
|
+
nonce,
|
|
191
|
+
details: txDetails != null ? txDetails : this._config.defaultTxDetails
|
|
192
|
+
};
|
|
193
|
+
const response = yield this.signAndSubmitTransaction(
|
|
194
|
+
unsignedTx,
|
|
195
|
+
{
|
|
196
|
+
signer
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
return {
|
|
200
|
+
response,
|
|
201
|
+
unsignedTx
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
get client() {
|
|
206
|
+
return this._client;
|
|
207
|
+
}
|
|
208
|
+
get serializer() {
|
|
209
|
+
return this._serializer;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
213
|
+
0 && (module.exports = {
|
|
214
|
+
SovereignError,
|
|
215
|
+
StandardRollup,
|
|
216
|
+
createSerializer
|
|
217
|
+
});
|
|
5
218
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/rollup.ts","../src/serialization.ts","../src/errors.ts","../src/utils.ts"],"sourcesContent":["export * from \"./signer\";\nexport * from \"./rollup\";\nexport * from \"./serialization\";\nexport * from \"./errors\";\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport { Base64 } from \"js-base64\";\nimport {\n type RollupSchema,\n type RollupSerializer,\n createSerializer,\n} from \"./serialization\";\nimport type { Signer } from \"./signer\";\nimport { bytesToHex } from \"./utils\";\n\nexport type RollupCallResult = {\n response: SovereignClient.Sequencer.TxCreateResponse;\n unsignedTx: unknown;\n};\n\nexport type RollupConfig = {\n url?: string;\n schema: RollupSchema;\n defaultTxDetails: TxDetails;\n};\n\ntype TxDetails = {\n max_priority_fee_bips: number;\n max_fee: bigint;\n gas_limit?: bigint;\n chain_id: bigint;\n};\n\ntype SignerParams = {\n signer: Signer;\n};\n\ntype CallParams = {\n txDetails?: TxDetails;\n} & SignerParams;\n\nexport class StandardRollup<Tx = unknown, UnsignedTx = unknown> {\n private readonly _config: RollupConfig;\n private readonly _client: SovereignClient;\n private readonly _serializer: RollupSerializer;\n\n constructor(config: RollupConfig) {\n this._client = new SovereignClient({ baseURL: config.url });\n this._serializer = createSerializer(config.schema);\n this._config = config;\n }\n\n async submitTransaction(\n transaction: Tx,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedTx = this.serializer.serializeTx(transaction);\n\n return this.client.sequencer.txs.create({\n body: Base64.fromUint8Array(serializedTx),\n });\n }\n\n async signAndSubmitTransaction(\n unsignedTx: UnsignedTx,\n { signer }: SignerParams,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedUnsignedTx =\n this.serializer.serializeUnsignedTx(unsignedTx);\n const signature = await signer.sign(serializedUnsignedTx);\n const publicKey = await signer.publicKey();\n const tx = {\n pub_key: {\n pub_key: publicKey,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\n };\n\n return this.submitTransaction(tx as Tx);\n }\n\n async call(\n runtimeMessage: unknown,\n { signer, txDetails }: CallParams,\n ): Promise<RollupCallResult> {\n const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const dedup = await this.client.rollup.addresses.dedup.retrieve(\n bytesToHex(publicKey),\n );\n // biome-ignore lint/suspicious/noExplicitAny: fix later\n const nonce = (dedup.data as any).nonce as number;\n const unsignedTx = {\n runtime_msg: runtimeCall,\n nonce,\n details: txDetails ?? this._config.defaultTxDetails,\n };\n const response = await this.signAndSubmitTransaction(\n unsignedTx as UnsignedTx,\n {\n signer,\n },\n );\n\n return {\n response,\n unsignedTx,\n };\n }\n\n get client(): SovereignClient {\n return this._client;\n }\n\n get serializer(): RollupSerializer {\n return this._serializer;\n }\n}\n","import { KnownTypeId, Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\nimport { SovereignError } from \"./errors\";\n\nexport type RollupSchema = object;\n\nexport type RollupSerializer = {\n serialize(input: unknown, index: number): Uint8Array;\n serializeRuntimeCall(input: unknown): Uint8Array;\n serializeUnsignedTx(input: unknown): Uint8Array;\n serializeTx(input: unknown): Uint8Array;\n};\n\nfunction loadSchema(schemaObject: RollupSchema): Schema {\n try {\n return Schema.fromJSON(JSON.stringify(schemaObject));\n } catch (err) {\n throw new SovereignError(`Failed to create runtime schema due to: ${err}`);\n }\n}\n\nexport function createSerializer(schemaObject: RollupSchema): RollupSerializer {\n const schema = loadSchema(schemaObject);\n\n return {\n serialize(input: unknown, index: number): Uint8Array {\n try {\n return schema.jsonToBorsh(\n index,\n JSON.stringify(input, (_, value) => {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n return value;\n }),\n );\n } catch (err) {\n throw new SovereignError(`Failed to serialize input due to: ${err}`);\n }\n },\n serializeRuntimeCall(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.RuntimeCall),\n );\n },\n serializeUnsignedTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.UnsignedTransaction),\n );\n },\n serializeTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.Transaction),\n );\n },\n };\n}\n","export class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n","export function hexToBytes(hex: string) {\n if (hex.length && hex.length % 2 !== 0) {\n throw new Error(`Invalid hex string length: ${hex.length}`);\n }\n\n const matches = hex.match(/[\\da-f]{2}/gi);\n\n if (!matches) {\n throw new Error(\"Invalid hex string: No valid hex digits found\");\n }\n\n return new Uint8Array(matches.map((h) => Number.parseInt(h, 16)));\n}\n\nexport function bytesToHex(arr: Uint8Array): string {\n let hex = \"\";\n for (let i = 0; i < arr.length; i++) {\n let hexValue = arr[i].toString(16);\n if (hexValue.length === 1) {\n hexValue = `0${hexValue}`;\n }\n hex += hexValue;\n }\n return hex;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA4B;AAC5B,uBAAuB;;;ACDvB,mCAAoC;;;ACA7B,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,QAAQ,IAAI,MAAM,EAAE;AAAA,EAC3B;AACF;;;ADKA,SAAS,WAAW,cAAoC;AACtD,MAAI;AACF,WAAO,oCAAO,SAAS,KAAK,UAAU,YAAY,CAAC;AAAA,EACrD,SAAS,KAAK;AACZ,UAAM,IAAI,eAAe,2CAA2C,GAAG,EAAE;AAAA,EAC3E;AACF;AAEO,SAAS,iBAAiB,cAA8C;AAC7E,QAAM,SAAS,WAAW,YAAY;AAEtC,SAAO;AAAA,IACL,UAAU,OAAgB,OAA2B;AACnD,UAAI;AACF,eAAO,OAAO;AAAA,UACZ;AAAA,UACA,KAAK,UAAU,O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,yBACJ,IACA,IACqD;AAAA,+CAFrD,YACA,EAAE,OAAO,GAC4C;AACrD,YAAM,uBACJ,KAAK,WAAW,oBAAoB,UAAU;AAChD,YAAM,YAAY,MAAM,OAAO,KAAK,oBAAoB;AACxD,YAAM,YAAY,MAAM,OAAO,UAAU;AACzC,YAAM,KAAK;AAAA,QACT,SAAS;AAAA,UACP,SAAS;AAAA,QACX;AAAA,QACA,WAAW;AAAA,UACT,SAAS;AAAA,QACX;AAAA,SACG;AAGL,aAAO,KAAK,kBAAkB,EAAQ;AAAA,IACxC;AAAA;AAAA,EAEM,KACJ,IACA,IAC2B;AAAA,+CAF3B,gBACA,EAAE,QAAQ,UAAU,GACO;AAC3B,YAAM,cAAc,KAAK,WAAW,qBAAqB,cAAc;AACvE,YAAM,YAAY,MAAM,OAAO,UAAU;AACzC,YAAM,QAAQ,MAAM,KAAK,OAAO,OAAO,UAAU,MAAM;AAAA,QACrD,WAAW,SAAS;AAAA,MACtB;AAEA,YAAM,QAAS,MAAM,KAAa;AAClC,YAAM,aAAa;AAAA,QACjB,aAAa;AAAA,QACb;AAAA,QACA,SAAS,gCAAa,KAAK,QAAQ;AAAA,MACrC;AACA,YAAM,WAAW,MAAM,KAAK;AAAA,QAC1B;AAAA,QACA;AAAA,UACE;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA;AAAA,EAEA,IAAI,SAA0B;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,aAA+B;AACjC,WAAO,KAAK;AAAA,EACd;AACF;","names":["SovereignClient"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/rollup.ts
|
|
39
|
+
import SovereignClient from "@sovereign-sdk/client";
|
|
40
|
+
import { Base64 } from "js-base64";
|
|
41
|
+
|
|
42
|
+
// src/serialization.ts
|
|
43
|
+
import { KnownTypeId, Schema } from "@sovereign-sdk/universal-wallet-wasm";
|
|
44
|
+
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var SovereignError = class extends Error {
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = this.constructor.name;
|
|
50
|
+
this.stack = new Error().stack;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/serialization.ts
|
|
55
|
+
function loadSchema(schemaObject) {
|
|
56
|
+
try {
|
|
57
|
+
return Schema.fromJSON(JSON.stringify(schemaObject));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
throw new SovereignError(`Failed to create runtime schema due to: ${err}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function createSerializer(schemaObject) {
|
|
63
|
+
const schema = loadSchema(schemaObject);
|
|
64
|
+
return {
|
|
65
|
+
serialize(input, index) {
|
|
66
|
+
try {
|
|
67
|
+
return schema.jsonToBorsh(
|
|
68
|
+
index,
|
|
69
|
+
JSON.stringify(input, (_, value) => {
|
|
70
|
+
if (value instanceof Uint8Array) {
|
|
71
|
+
return Array.from(value);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
throw new SovereignError(`Failed to serialize input due to: ${err}`);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
serializeRuntimeCall(input) {
|
|
81
|
+
return this.serialize(
|
|
82
|
+
input,
|
|
83
|
+
schema.knownTypeIndex(KnownTypeId.RuntimeCall)
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
serializeUnsignedTx(input) {
|
|
87
|
+
return this.serialize(
|
|
88
|
+
input,
|
|
89
|
+
schema.knownTypeIndex(KnownTypeId.UnsignedTransaction)
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
serializeTx(input) {
|
|
93
|
+
return this.serialize(
|
|
94
|
+
input,
|
|
95
|
+
schema.knownTypeIndex(KnownTypeId.Transaction)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/utils.ts
|
|
102
|
+
function bytesToHex(arr) {
|
|
103
|
+
let hex = "";
|
|
104
|
+
for (let i = 0; i < arr.length; i++) {
|
|
105
|
+
let hexValue = arr[i].toString(16);
|
|
106
|
+
if (hexValue.length === 1) {
|
|
107
|
+
hexValue = `0${hexValue}`;
|
|
108
|
+
}
|
|
109
|
+
hex += hexValue;
|
|
110
|
+
}
|
|
111
|
+
return hex;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/rollup.ts
|
|
115
|
+
var StandardRollup = class {
|
|
116
|
+
constructor(config) {
|
|
117
|
+
this._client = new SovereignClient({ baseURL: config.url });
|
|
118
|
+
this._serializer = createSerializer(config.schema);
|
|
119
|
+
this._config = config;
|
|
120
|
+
}
|
|
121
|
+
submitTransaction(transaction) {
|
|
122
|
+
return __async(this, null, function* () {
|
|
123
|
+
const serializedTx = this.serializer.serializeTx(transaction);
|
|
124
|
+
return this.client.sequencer.txs.create({
|
|
125
|
+
body: Base64.fromUint8Array(serializedTx)
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
signAndSubmitTransaction(_0, _1) {
|
|
130
|
+
return __async(this, arguments, function* (unsignedTx, { signer }) {
|
|
131
|
+
const serializedUnsignedTx = this.serializer.serializeUnsignedTx(unsignedTx);
|
|
132
|
+
const signature = yield signer.sign(serializedUnsignedTx);
|
|
133
|
+
const publicKey = yield signer.publicKey();
|
|
134
|
+
const tx = __spreadValues({
|
|
135
|
+
pub_key: {
|
|
136
|
+
pub_key: publicKey
|
|
137
|
+
},
|
|
138
|
+
signature: {
|
|
139
|
+
msg_sig: signature
|
|
140
|
+
}
|
|
141
|
+
}, unsignedTx);
|
|
142
|
+
return this.submitTransaction(tx);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
call(_0, _1) {
|
|
146
|
+
return __async(this, arguments, function* (runtimeMessage, { signer, txDetails }) {
|
|
147
|
+
const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
|
|
148
|
+
const publicKey = yield signer.publicKey();
|
|
149
|
+
const dedup = yield this.client.rollup.addresses.dedup.retrieve(
|
|
150
|
+
bytesToHex(publicKey)
|
|
151
|
+
);
|
|
152
|
+
const nonce = dedup.data.nonce;
|
|
153
|
+
const unsignedTx = {
|
|
154
|
+
runtime_msg: runtimeCall,
|
|
155
|
+
nonce,
|
|
156
|
+
details: txDetails != null ? txDetails : this._config.defaultTxDetails
|
|
157
|
+
};
|
|
158
|
+
const response = yield this.signAndSubmitTransaction(
|
|
159
|
+
unsignedTx,
|
|
160
|
+
{
|
|
161
|
+
signer
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
return {
|
|
165
|
+
response,
|
|
166
|
+
unsignedTx
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
get client() {
|
|
171
|
+
return this._client;
|
|
172
|
+
}
|
|
173
|
+
get serializer() {
|
|
174
|
+
return this._serializer;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
export {
|
|
178
|
+
SovereignError,
|
|
179
|
+
StandardRollup,
|
|
180
|
+
createSerializer
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rollup.ts","../src/serialization.ts","../src/errors.ts","../src/utils.ts"],"sourcesContent":["import SovereignClient from \"@sovereign-sdk/client\";\nimport { Base64 } from \"js-base64\";\nimport {\n type RollupSchema,\n type RollupSerializer,\n createSerializer,\n} from \"./serialization\";\nimport type { Signer } from \"./signer\";\nimport { bytesToHex } from \"./utils\";\n\nexport type RollupCallResult = {\n response: SovereignClient.Sequencer.TxCreateResponse;\n unsignedTx: unknown;\n};\n\nexport type RollupConfig = {\n url?: string;\n schema: RollupSchema;\n defaultTxDetails: TxDetails;\n};\n\ntype TxDetails = {\n max_priority_fee_bips: number;\n max_fee: bigint;\n gas_limit?: bigint;\n chain_id: bigint;\n};\n\ntype SignerParams = {\n signer: Signer;\n};\n\ntype CallParams = {\n txDetails?: TxDetails;\n} & SignerParams;\n\nexport class StandardRollup<Tx = unknown, UnsignedTx = unknown> {\n private readonly _config: RollupConfig;\n private readonly _client: SovereignClient;\n private readonly _serializer: RollupSerializer;\n\n constructor(config: RollupConfig) {\n this._client = new SovereignClient({ baseURL: config.url });\n this._serializer = createSerializer(config.schema);\n this._config = config;\n }\n\n async submitTransaction(\n transaction: Tx,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedTx = this.serializer.serializeTx(transaction);\n\n return this.client.sequencer.txs.create({\n body: Base64.fromUint8Array(serializedTx),\n });\n }\n\n async signAndSubmitTransaction(\n unsignedTx: UnsignedTx,\n { signer }: SignerParams,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedUnsignedTx =\n this.serializer.serializeUnsignedTx(unsignedTx);\n const signature = await signer.sign(serializedUnsignedTx);\n const publicKey = await signer.publicKey();\n const tx = {\n pub_key: {\n pub_key: publicKey,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\n };\n\n return this.submitTransaction(tx as Tx);\n }\n\n async call(\n runtimeMessage: unknown,\n { signer, txDetails }: CallParams,\n ): Promise<RollupCallResult> {\n const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const dedup = await this.client.rollup.addresses.dedup.retrieve(\n bytesToHex(publicKey),\n );\n // biome-ignore lint/suspicious/noExplicitAny: fix later\n const nonce = (dedup.data as any).nonce as number;\n const unsignedTx = {\n runtime_msg: runtimeCall,\n nonce,\n details: txDetails ?? this._config.defaultTxDetails,\n };\n const response = await this.signAndSubmitTransaction(\n unsignedTx as UnsignedTx,\n {\n signer,\n },\n );\n\n return {\n response,\n unsignedTx,\n };\n }\n\n get client(): SovereignClient {\n return this._client;\n }\n\n get serializer(): RollupSerializer {\n return this._serializer;\n }\n}\n","import { KnownTypeId, Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\nimport { SovereignError } from \"./errors\";\n\nexport type RollupSchema = object;\n\nexport type RollupSerializer = {\n serialize(input: unknown, index: number): Uint8Array;\n serializeRuntimeCall(input: unknown): Uint8Array;\n serializeUnsignedTx(input: unknown): Uint8Array;\n serializeTx(input: unknown): Uint8Array;\n};\n\nfunction loadSchema(schemaObject: RollupSchema): Schema {\n try {\n return Schema.fromJSON(JSON.stringify(schemaObject));\n } catch (err) {\n throw new SovereignError(`Failed to create runtime schema due to: ${err}`);\n }\n}\n\nexport function createSerializer(schemaObject: RollupSchema): RollupSerializer {\n const schema = loadSchema(schemaObject);\n\n return {\n serialize(input: unknown, index: number): Uint8Array {\n try {\n return schema.jsonToBorsh(\n index,\n JSON.stringify(input, (_, value) => {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n return value;\n }),\n );\n } catch (err) {\n throw new SovereignError(`Failed to serialize input due to: ${err}`);\n }\n },\n serializeRuntimeCall(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.RuntimeCall),\n );\n },\n serializeUnsignedTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.UnsignedTransaction),\n );\n },\n serializeTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.Transaction),\n );\n },\n };\n}\n","export class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n","export function hexToBytes(hex: string) {\n if (hex.length && hex.length % 2 !== 0) {\n throw new Error(`Invalid hex string length: ${hex.length}`);\n }\n\n const matches = hex.match(/[\\da-f]{2}/gi);\n\n if (!matches) {\n throw new Error(\"Invalid hex string: No valid hex digits found\");\n }\n\n return new Uint8Array(matches.map((h) => Number.parseInt(h, 16)));\n}\n\nexport function bytesToHex(arr: Uint8Array): string {\n let hex = \"\";\n for (let i = 0; i < arr.length; i++) {\n let hexValue = arr[i].toString(16);\n if (hexValue.length === 1) {\n hexValue = `0${hexValue}`;\n }\n hex += hexValue;\n }\n return hex;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,aAAa;AAAA,QACb;AAAA,QACA,SAAS,gCAAa,KAAK,QAAQ;AAAA,MACrC;AACA,YAAM,WAAW,MAAM,KAAK;AAAA,QAC1B;AAAA,QACA;AAAA,UACE;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA;AAAA,EAEA,IAAI,SAA0B;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,aAA+B;AACjC,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sovereign-sdk/web3",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"package.json"
|
|
@@ -8,13 +8,16 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
15
17
|
"types": "./dist/index.d.ts",
|
|
16
18
|
"devDependencies": {
|
|
17
19
|
"@biomejs/biome": "^1.9.2",
|
|
20
|
+
"tsup": "^8.3.0",
|
|
18
21
|
"vitest": "^2.1.1"
|
|
19
22
|
},
|
|
20
23
|
"peerDependencies": {
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
"access": "public"
|
|
30
33
|
},
|
|
31
34
|
"scripts": {
|
|
32
|
-
"build": "
|
|
35
|
+
"build": "tsup",
|
|
33
36
|
"ci": "biome ci",
|
|
34
37
|
"fix": "biome check --write",
|
|
35
38
|
"lint": "biome lint",
|
package/dist/errors.d.ts
DELETED
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAY5B"}
|
package/dist/errors.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export class SovereignError extends Error {
|
|
2
|
-
constructor(message) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.name = this.constructor.name;
|
|
5
|
-
// `Error.captureStackTrace` is v8 specific API,
|
|
6
|
-
// add fallback for compatibility in other envs
|
|
7
|
-
if (Error.captureStackTrace) {
|
|
8
|
-
Error.captureStackTrace(this, this.constructor);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
this.stack = new Error().stack;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAElC,gDAAgD;QAChD,+CAA+C;QAC/C,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
package/dist/index.test.d.ts
DELETED
package/dist/index.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
package/dist/index.test.js
DELETED
package/dist/index.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;IACrB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
package/dist/rollup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC;IACrD,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,gBAAgB,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,YAAY,CAAC;AAEjB,qBAAa,cAAc,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;gBAEnC,MAAM,EAAE,YAAY;IAM1B,iBAAiB,CACrB,WAAW,EAAE,EAAE,GACd,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAQhD,wBAAwB,CAC5B,UAAU,EAAE,UAAU,EACtB,EAAE,MAAM,EAAE,EAAE,YAAY,GACvB,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAgBhD,IAAI,CACR,cAAc,EAAE,OAAO,EACvB,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU,GAChC,OAAO,CAAC,gBAAgB,CAAC;IA0B5B,IAAI,MAAM,IAAI,eAAe,CAE5B;IAED,IAAI,UAAU,IAAI,gBAAgB,CAEjC;CACF"}
|
package/dist/rollup.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import SovereignClient from "@sovereign-sdk/client";
|
|
11
|
-
import { Base64 } from "js-base64";
|
|
12
|
-
import { createSerializer, } from "./serialization";
|
|
13
|
-
import { bytesToHex } from "./utils";
|
|
14
|
-
export class StandardRollup {
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this._client = new SovereignClient({ baseURL: config.url });
|
|
17
|
-
this._serializer = createSerializer(config.schema);
|
|
18
|
-
this._config = config;
|
|
19
|
-
}
|
|
20
|
-
submitTransaction(transaction) {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const serializedTx = this.serializer.serializeTx(transaction);
|
|
23
|
-
return this.client.sequencer.txs.create({
|
|
24
|
-
body: Base64.fromUint8Array(serializedTx),
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
signAndSubmitTransaction(unsignedTx_1, _a) {
|
|
29
|
-
return __awaiter(this, arguments, void 0, function* (unsignedTx, { signer }) {
|
|
30
|
-
const serializedUnsignedTx = this.serializer.serializeUnsignedTx(unsignedTx);
|
|
31
|
-
const signature = yield signer.sign(serializedUnsignedTx);
|
|
32
|
-
const publicKey = yield signer.publicKey();
|
|
33
|
-
const tx = Object.assign({ pub_key: publicKey, signature: {
|
|
34
|
-
msg_sig: signature,
|
|
35
|
-
} }, unsignedTx);
|
|
36
|
-
return this.submitTransaction(tx);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
call(runtimeMessage_1, _a) {
|
|
40
|
-
return __awaiter(this, arguments, void 0, function* (runtimeMessage, { signer, txDetails }) {
|
|
41
|
-
const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
|
|
42
|
-
const publicKey = yield signer.publicKey();
|
|
43
|
-
const dedup = yield this.client.rollup.addresses.dedup.retrieve(bytesToHex(publicKey));
|
|
44
|
-
// biome-ignore lint/suspicious/noExplicitAny: fix later
|
|
45
|
-
const nonce = BigInt(dedup.data.nonce);
|
|
46
|
-
const unsignedTx = {
|
|
47
|
-
runtime_msg: runtimeCall,
|
|
48
|
-
nonce,
|
|
49
|
-
details: txDetails !== null && txDetails !== void 0 ? txDetails : this._config.defaultTxDetails,
|
|
50
|
-
};
|
|
51
|
-
const response = yield this.signAndSubmitTransaction(unsignedTx, {
|
|
52
|
-
signer,
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
response,
|
|
56
|
-
unsignedTx,
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
get client() {
|
|
61
|
-
return this._client;
|
|
62
|
-
}
|
|
63
|
-
get serializer() {
|
|
64
|
-
return this._serializer;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=rollup.js.map
|
package/dist/rollup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAGL,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA4BrC,MAAM,OAAO,cAAc;IAKzB,YAAY,MAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEK,iBAAiB,CACrB,WAAe;;YAEf,MAAM,YAAY,GAAG,IA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AAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;aACpD,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAClD,UAAwB,EACxB;gBACE,MAAM;aACP,CACF,CAAC;YAEF,OAAO;gBACL,QAAQ;gBACR,UAAU;aACX,CAAC;QACJ,CAAC;KAAA;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/serialization.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type RollupSchema = object;
|
|
2
|
-
export type RollupSerializer = {
|
|
3
|
-
serialize(input: unknown, index: number): Uint8Array;
|
|
4
|
-
serializeRuntimeCall(input: unknown): Uint8Array;
|
|
5
|
-
serializeUnsignedTx(input: unknown): Uint8Array;
|
|
6
|
-
serializeTx(input: unknown): Uint8Array;
|
|
7
|
-
};
|
|
8
|
-
export declare function createSerializer(schemaObject: RollupSchema): RollupSerializer;
|
|
9
|
-
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACrD,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC;IACjD,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC;IAChD,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC;CACzC,CAAC;AAYF,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,gBAAgB,CAgC7E"}
|
package/dist/serialization.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { KnownTypeId, Schema } from "@sovereign-sdk/universal-wallet-wasm";
|
|
2
|
-
import { SovereignError } from "./errors";
|
|
3
|
-
function loadSchema(schemaObject) {
|
|
4
|
-
try {
|
|
5
|
-
return Schema.fromJSON(JSON.stringify(schemaObject));
|
|
6
|
-
}
|
|
7
|
-
catch (err) {
|
|
8
|
-
throw new SovereignError(`Failed to create runtime schema due to: ${err.message}`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export function createSerializer(schemaObject) {
|
|
12
|
-
const schema = loadSchema(schemaObject);
|
|
13
|
-
return {
|
|
14
|
-
serialize(input, index) {
|
|
15
|
-
try {
|
|
16
|
-
return schema.jsonToBorsh(index, JSON.stringify(input));
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
throw new SovereignError(`Failed to serialize input due to: ${err.message}`);
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
serializeRuntimeCall(input) {
|
|
23
|
-
return this.serialize(input, schema.knownTypeIndex(KnownTypeId.RuntimeCall));
|
|
24
|
-
},
|
|
25
|
-
serializeUnsignedTx(input) {
|
|
26
|
-
return this.serialize(input, schema.knownTypeIndex(KnownTypeId.UnsignedTransaction));
|
|
27
|
-
},
|
|
28
|
-
serializeTx(input) {
|
|
29
|
-
return this.serialize(input, schema.knownTypeIndex(KnownTypeId.Transaction));
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=serialization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW1C,SAAS,UAAU,CAAC,YAA0B;IAC5C,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,cAAc,CACtB,2CAA4C,GAAa,CAAC,OAAO,EAAE,CACpE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,YAA0B;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAExC,OAAO;QACL,SAAS,CAAC,KAAc,EAAE,KAAa;YACrC,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,cAAc,CACtB,qCAAsC,GAAa,CAAC,OAAO,EAAE,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;QACD,oBAAoB,CAAC,KAAc;YACjC,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,EACL,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC,CAC/C,CAAC;QACJ,CAAC;QACD,mBAAmB,CAAC,KAAc;YAChC,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,EACL,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,mBAAmB,CAAC,CACvD,CAAC;QACJ,CAAC;QACD,WAAW,CAAC,KAAc;YACxB,OAAO,IAAI,CAAC,SAAS,CACnB,KAAK,EACL,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC,CAC/C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/signer.d.ts
DELETED
package/dist/signer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;CAClC"}
|
package/dist/signer.js
DELETED
package/dist/signer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
DELETED
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,cAYrC;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAUlD"}
|
package/dist/utils.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function hexToBytes(hex) {
|
|
2
|
-
if (hex.length && hex.length % 2 !== 0) {
|
|
3
|
-
throw new Error(`Invalid hex string length: ${hex.length}`);
|
|
4
|
-
}
|
|
5
|
-
const matches = hex.match(/[\da-f]{2}/gi);
|
|
6
|
-
if (!matches) {
|
|
7
|
-
throw new Error("Invalid hex string: No valid hex digits found");
|
|
8
|
-
}
|
|
9
|
-
return new Uint8Array(matches.map((h) => Number.parseInt(h, 16)));
|
|
10
|
-
}
|
|
11
|
-
export function bytesToHex(arr) {
|
|
12
|
-
let hex = "";
|
|
13
|
-
for (let i = 0; i < arr.length; i++) {
|
|
14
|
-
let hexValue = arr[i].toString(16);
|
|
15
|
-
if (hexValue.length === 1) {
|
|
16
|
-
hexValue = `0${hexValue}`;
|
|
17
|
-
}
|
|
18
|
-
hex += hexValue;
|
|
19
|
-
}
|
|
20
|
-
return hex;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAe;IACxC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,CAAC;QACD,GAAG,IAAI,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|