@cartridge/controller-wasm 0.1.0

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/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *
package/README.md ADDED
File without changes
@@ -0,0 +1,163 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export enum ErrorCode {
4
+ StarknetFailedToReceiveTransaction = 1,
5
+ StarknetContractNotFound = 20,
6
+ StarknetBlockNotFound = 24,
7
+ StarknetInvalidTransactionIndex = 27,
8
+ StarknetClassHashNotFound = 28,
9
+ StarknetTransactionHashNotFound = 29,
10
+ StarknetPageSizeTooBig = 31,
11
+ StarknetNoBlocks = 32,
12
+ StarknetInvalidContinuationToken = 33,
13
+ StarknetTooManyKeysInFilter = 34,
14
+ StarknetContractError = 40,
15
+ StarknetTransactionExecutionError = 41,
16
+ StarknetClassAlreadyDeclared = 51,
17
+ StarknetInvalidTransactionNonce = 52,
18
+ StarknetInsufficientMaxFee = 53,
19
+ StarknetInsufficientAccountBalance = 54,
20
+ StarknetValidationFailure = 55,
21
+ StarknetCompilationFailed = 56,
22
+ StarknetContractClassSizeIsTooLarge = 57,
23
+ StarknetNonAccount = 58,
24
+ StarknetDuplicateTx = 59,
25
+ StarknetCompiledClassHashMismatch = 60,
26
+ StarknetUnsupportedTxVersion = 61,
27
+ StarknetUnsupportedContractClassVersion = 62,
28
+ StarknetUnexpectedError = 63,
29
+ StarknetNoTraceAvailable = 10,
30
+ SignError = 101,
31
+ StorageError = 102,
32
+ AccountFactoryError = 103,
33
+ PaymasterExecutionTimeNotReached = 104,
34
+ PaymasterExecutionTimePassed = 105,
35
+ PaymasterInvalidCaller = 106,
36
+ PaymasterRateLimitExceeded = 107,
37
+ PaymasterNotSupported = 108,
38
+ PaymasterHttp = 109,
39
+ PaymasterExcecution = 110,
40
+ PaymasterSerialization = 111,
41
+ CartridgeControllerNotDeployed = 112,
42
+ InsufficientBalance = 113,
43
+ OriginError = 114,
44
+ EncodingError = 115,
45
+ SerdeWasmBindgenError = 116,
46
+ CairoSerdeError = 117,
47
+ CairoShortStringToFeltError = 118,
48
+ DeviceCreateCredential = 119,
49
+ DeviceGetAssertion = 120,
50
+ DeviceBadAssertion = 121,
51
+ DeviceChannel = 122,
52
+ DeviceOrigin = 123,
53
+ AccountSigning = 124,
54
+ AccountProvider = 125,
55
+ AccountClassHashCalculation = 126,
56
+ AccountClassCompression = 127,
57
+ AccountFeeOutOfRange = 128,
58
+ ProviderRateLimited = 129,
59
+ ProviderArrayLengthMismatch = 130,
60
+ ProviderOther = 131,
61
+ SessionAlreadyRegistered = 132,
62
+ UrlParseError = 133,
63
+ Base64DecodeError = 134,
64
+ CoseError = 135,
65
+ PolicyChainIdMismatch = 136,
66
+ }
67
+ export interface JsCall {
68
+ contractAddress: JsFelt;
69
+ entrypoint: string;
70
+ calldata: JsFelt[];
71
+ }
72
+
73
+ export type JsPriceUnit = "WEI" | "FRI";
74
+
75
+ export interface JsEstimateFeeDetails {
76
+ nonce: JsFelt;
77
+ }
78
+
79
+ export interface JsFeeEstimate {
80
+ gas_consumed: JsFelt;
81
+ gas_price: JsFelt;
82
+ overall_fee: JsFelt;
83
+ unit: JsPriceUnit;
84
+ data_gas_consumed: JsFelt;
85
+ data_gas_price: JsFelt;
86
+ }
87
+
88
+ export interface Owner {
89
+ signer?: Signer;
90
+ account?: JsFelt;
91
+ }
92
+
93
+ export interface CallPolicy {
94
+ target: JsFelt;
95
+ method: JsFelt;
96
+ authorized?: boolean;
97
+ }
98
+
99
+ export interface TypedDataPolicy {
100
+ scope_hash: JsFelt;
101
+ authorized?: boolean;
102
+ }
103
+
104
+ export type Policy = CallPolicy | TypedDataPolicy;
105
+
106
+ export interface WebauthnSigner {
107
+ rpId: string;
108
+ credentialId: string;
109
+ publicKey: string;
110
+ }
111
+
112
+ export interface StarknetSigner {
113
+ privateKey: JsFelt;
114
+ }
115
+
116
+ export interface Eip191Signer {
117
+ address: string;
118
+ }
119
+
120
+ export interface Signer {
121
+ webauthn?: WebauthnSigner;
122
+ starknet?: StarknetSigner;
123
+ eip191?: Eip191Signer;
124
+ }
125
+
126
+ export type JsFelt = Felt;
127
+
128
+ export type Felts = JsFelt[];
129
+
130
+ export type JsFeeSource = "PAYMASTER" | "CREDITS";
131
+
132
+ export interface AuthorizedSession {
133
+ session: Session;
134
+ authorization: JsFelt[] | null;
135
+ isRegistered: boolean;
136
+ expiresAt: number;
137
+ allowedPoliciesRoot: JsFelt;
138
+ metadataHash: JsFelt;
139
+ sessionKeyGuid: JsFelt;
140
+ guardianKeyGuid: JsFelt;
141
+ }
142
+
143
+ export interface Session {
144
+ policies: Policy[];
145
+ expiresAt: number;
146
+ metadataHash: JsFelt;
147
+ sessionKeyGuid: JsFelt;
148
+ guardianKeyGuid: JsFelt;
149
+ }
150
+
151
+ export interface Credentials {
152
+ authorization: JsFelt[];
153
+ privateKey: JsFelt;
154
+ }
155
+
156
+ export class JsControllerError {
157
+ private constructor();
158
+ free(): void;
159
+ code: ErrorCode;
160
+ message: string;
161
+ get data(): string | undefined;
162
+ set data(value: string | null | undefined);
163
+ }
@@ -0,0 +1,259 @@
1
+
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+ let wasm;
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
+
9
+ cachedTextDecoder.decode();
10
+
11
+ let cachedUint8ArrayMemory0 = null;
12
+
13
+ function getUint8ArrayMemory0() {
14
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
15
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
16
+ }
17
+ return cachedUint8ArrayMemory0;
18
+ }
19
+
20
+ function getStringFromWasm0(ptr, len) {
21
+ ptr = ptr >>> 0;
22
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
23
+ }
24
+
25
+ let cachedDataViewMemory0 = null;
26
+
27
+ function getDataViewMemory0() {
28
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
29
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
30
+ }
31
+ return cachedDataViewMemory0;
32
+ }
33
+
34
+ let WASM_VECTOR_LEN = 0;
35
+
36
+ let cachedTextEncoder = new TextEncoder('utf-8');
37
+
38
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
39
+ ? function (arg, view) {
40
+ return cachedTextEncoder.encodeInto(arg, view);
41
+ }
42
+ : function (arg, view) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ view.set(buf);
45
+ return {
46
+ read: arg.length,
47
+ written: buf.length
48
+ };
49
+ });
50
+
51
+ function passStringToWasm0(arg, malloc, realloc) {
52
+
53
+ if (realloc === undefined) {
54
+ const buf = cachedTextEncoder.encode(arg);
55
+ const ptr = malloc(buf.length, 1) >>> 0;
56
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
57
+ WASM_VECTOR_LEN = buf.length;
58
+ return ptr;
59
+ }
60
+
61
+ let len = arg.length;
62
+ let ptr = malloc(len, 1) >>> 0;
63
+
64
+ const mem = getUint8ArrayMemory0();
65
+
66
+ let offset = 0;
67
+
68
+ for (; offset < len; offset++) {
69
+ const code = arg.charCodeAt(offset);
70
+ if (code > 0x7F) break;
71
+ mem[ptr + offset] = code;
72
+ }
73
+
74
+ if (offset !== len) {
75
+ if (offset !== 0) {
76
+ arg = arg.slice(offset);
77
+ }
78
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
79
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
80
+ const ret = encodeString(arg, view);
81
+
82
+ offset += ret.written;
83
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
84
+ }
85
+
86
+ WASM_VECTOR_LEN = offset;
87
+ return ptr;
88
+ }
89
+
90
+ function isLikeNone(x) {
91
+ return x === undefined || x === null;
92
+ }
93
+ /**
94
+ * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136}
95
+ */
96
+ module.exports.ErrorCode = Object.freeze({
97
+ StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
98
+ StarknetContractNotFound: 20, "20": "StarknetContractNotFound",
99
+ StarknetBlockNotFound: 24, "24": "StarknetBlockNotFound",
100
+ StarknetInvalidTransactionIndex: 27, "27": "StarknetInvalidTransactionIndex",
101
+ StarknetClassHashNotFound: 28, "28": "StarknetClassHashNotFound",
102
+ StarknetTransactionHashNotFound: 29, "29": "StarknetTransactionHashNotFound",
103
+ StarknetPageSizeTooBig: 31, "31": "StarknetPageSizeTooBig",
104
+ StarknetNoBlocks: 32, "32": "StarknetNoBlocks",
105
+ StarknetInvalidContinuationToken: 33, "33": "StarknetInvalidContinuationToken",
106
+ StarknetTooManyKeysInFilter: 34, "34": "StarknetTooManyKeysInFilter",
107
+ StarknetContractError: 40, "40": "StarknetContractError",
108
+ StarknetTransactionExecutionError: 41, "41": "StarknetTransactionExecutionError",
109
+ StarknetClassAlreadyDeclared: 51, "51": "StarknetClassAlreadyDeclared",
110
+ StarknetInvalidTransactionNonce: 52, "52": "StarknetInvalidTransactionNonce",
111
+ StarknetInsufficientMaxFee: 53, "53": "StarknetInsufficientMaxFee",
112
+ StarknetInsufficientAccountBalance: 54, "54": "StarknetInsufficientAccountBalance",
113
+ StarknetValidationFailure: 55, "55": "StarknetValidationFailure",
114
+ StarknetCompilationFailed: 56, "56": "StarknetCompilationFailed",
115
+ StarknetContractClassSizeIsTooLarge: 57, "57": "StarknetContractClassSizeIsTooLarge",
116
+ StarknetNonAccount: 58, "58": "StarknetNonAccount",
117
+ StarknetDuplicateTx: 59, "59": "StarknetDuplicateTx",
118
+ StarknetCompiledClassHashMismatch: 60, "60": "StarknetCompiledClassHashMismatch",
119
+ StarknetUnsupportedTxVersion: 61, "61": "StarknetUnsupportedTxVersion",
120
+ StarknetUnsupportedContractClassVersion: 62, "62": "StarknetUnsupportedContractClassVersion",
121
+ StarknetUnexpectedError: 63, "63": "StarknetUnexpectedError",
122
+ StarknetNoTraceAvailable: 10, "10": "StarknetNoTraceAvailable",
123
+ SignError: 101, "101": "SignError",
124
+ StorageError: 102, "102": "StorageError",
125
+ AccountFactoryError: 103, "103": "AccountFactoryError",
126
+ PaymasterExecutionTimeNotReached: 104, "104": "PaymasterExecutionTimeNotReached",
127
+ PaymasterExecutionTimePassed: 105, "105": "PaymasterExecutionTimePassed",
128
+ PaymasterInvalidCaller: 106, "106": "PaymasterInvalidCaller",
129
+ PaymasterRateLimitExceeded: 107, "107": "PaymasterRateLimitExceeded",
130
+ PaymasterNotSupported: 108, "108": "PaymasterNotSupported",
131
+ PaymasterHttp: 109, "109": "PaymasterHttp",
132
+ PaymasterExcecution: 110, "110": "PaymasterExcecution",
133
+ PaymasterSerialization: 111, "111": "PaymasterSerialization",
134
+ CartridgeControllerNotDeployed: 112, "112": "CartridgeControllerNotDeployed",
135
+ InsufficientBalance: 113, "113": "InsufficientBalance",
136
+ OriginError: 114, "114": "OriginError",
137
+ EncodingError: 115, "115": "EncodingError",
138
+ SerdeWasmBindgenError: 116, "116": "SerdeWasmBindgenError",
139
+ CairoSerdeError: 117, "117": "CairoSerdeError",
140
+ CairoShortStringToFeltError: 118, "118": "CairoShortStringToFeltError",
141
+ DeviceCreateCredential: 119, "119": "DeviceCreateCredential",
142
+ DeviceGetAssertion: 120, "120": "DeviceGetAssertion",
143
+ DeviceBadAssertion: 121, "121": "DeviceBadAssertion",
144
+ DeviceChannel: 122, "122": "DeviceChannel",
145
+ DeviceOrigin: 123, "123": "DeviceOrigin",
146
+ AccountSigning: 124, "124": "AccountSigning",
147
+ AccountProvider: 125, "125": "AccountProvider",
148
+ AccountClassHashCalculation: 126, "126": "AccountClassHashCalculation",
149
+ AccountClassCompression: 127, "127": "AccountClassCompression",
150
+ AccountFeeOutOfRange: 128, "128": "AccountFeeOutOfRange",
151
+ ProviderRateLimited: 129, "129": "ProviderRateLimited",
152
+ ProviderArrayLengthMismatch: 130, "130": "ProviderArrayLengthMismatch",
153
+ ProviderOther: 131, "131": "ProviderOther",
154
+ SessionAlreadyRegistered: 132, "132": "SessionAlreadyRegistered",
155
+ UrlParseError: 133, "133": "UrlParseError",
156
+ Base64DecodeError: 134, "134": "Base64DecodeError",
157
+ CoseError: 135, "135": "CoseError",
158
+ PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
159
+ });
160
+
161
+ const JsControllerErrorFinalization = (typeof FinalizationRegistry === 'undefined')
162
+ ? { register: () => {}, unregister: () => {} }
163
+ : new FinalizationRegistry(ptr => wasm.__wbg_jscontrollererror_free(ptr >>> 0, 1));
164
+
165
+ class JsControllerError {
166
+
167
+ __destroy_into_raw() {
168
+ const ptr = this.__wbg_ptr;
169
+ this.__wbg_ptr = 0;
170
+ JsControllerErrorFinalization.unregister(this);
171
+ return ptr;
172
+ }
173
+
174
+ free() {
175
+ const ptr = this.__destroy_into_raw();
176
+ wasm.__wbg_jscontrollererror_free(ptr, 0);
177
+ }
178
+ /**
179
+ * @returns {ErrorCode}
180
+ */
181
+ get code() {
182
+ const ret = wasm.__wbg_get_jscontrollererror_code(this.__wbg_ptr);
183
+ return ret;
184
+ }
185
+ /**
186
+ * @param {ErrorCode} arg0
187
+ */
188
+ set code(arg0) {
189
+ wasm.__wbg_set_jscontrollererror_code(this.__wbg_ptr, arg0);
190
+ }
191
+ /**
192
+ * @returns {string}
193
+ */
194
+ get message() {
195
+ let deferred1_0;
196
+ let deferred1_1;
197
+ try {
198
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
199
+ wasm.__wbg_get_jscontrollererror_message(retptr, this.__wbg_ptr);
200
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
201
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
202
+ deferred1_0 = r0;
203
+ deferred1_1 = r1;
204
+ return getStringFromWasm0(r0, r1);
205
+ } finally {
206
+ wasm.__wbindgen_add_to_stack_pointer(16);
207
+ wasm.__wbindgen_export_0(deferred1_0, deferred1_1, 1);
208
+ }
209
+ }
210
+ /**
211
+ * @param {string} arg0
212
+ */
213
+ set message(arg0) {
214
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ wasm.__wbg_set_jscontrollererror_message(this.__wbg_ptr, ptr0, len0);
217
+ }
218
+ /**
219
+ * @returns {string | undefined}
220
+ */
221
+ get data() {
222
+ try {
223
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
224
+ wasm.__wbg_get_jscontrollererror_data(retptr, this.__wbg_ptr);
225
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
226
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
227
+ let v1;
228
+ if (r0 !== 0) {
229
+ v1 = getStringFromWasm0(r0, r1).slice();
230
+ wasm.__wbindgen_export_0(r0, r1 * 1, 1);
231
+ }
232
+ return v1;
233
+ } finally {
234
+ wasm.__wbindgen_add_to_stack_pointer(16);
235
+ }
236
+ }
237
+ /**
238
+ * @param {string | null} [arg0]
239
+ */
240
+ set data(arg0) {
241
+ var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
242
+ var len0 = WASM_VECTOR_LEN;
243
+ wasm.__wbg_set_jscontrollererror_data(this.__wbg_ptr, ptr0, len0);
244
+ }
245
+ }
246
+ module.exports.JsControllerError = JsControllerError;
247
+
248
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
249
+ throw new Error(getStringFromWasm0(arg0, arg1));
250
+ };
251
+
252
+ const path = require('path').join(__dirname, 'account_wasm_bg.wasm');
253
+ const bytes = require('fs').readFileSync(path);
254
+
255
+ const wasmModule = new WebAssembly.Module(bytes);
256
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
257
+ wasm = wasmInstance.exports;
258
+ module.exports.__wasm = wasm;
259
+
Binary file
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_jscontrollererror_free: (a: number, b: number) => void;
5
+ export const __wbg_get_jscontrollererror_code: (a: number) => number;
6
+ export const __wbg_set_jscontrollererror_code: (a: number, b: number) => void;
7
+ export const __wbg_get_jscontrollererror_message: (a: number, b: number) => void;
8
+ export const __wbg_set_jscontrollererror_message: (a: number, b: number, c: number) => void;
9
+ export const __wbg_get_jscontrollererror_data: (a: number, b: number) => void;
10
+ export const __wbg_set_jscontrollererror_data: (a: number, b: number, c: number) => void;
11
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
12
+ export const __wbindgen_export_0: (a: number, b: number, c: number) => void;
13
+ export const __wbindgen_export_1: (a: number, b: number) => number;
14
+ export const __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@cartridge/controller-wasm",
3
+ "version": "0.1.0",
4
+ "files": "[\"*.js\", \"*.wasm\", \"*.d.ts\"]",
5
+ "main": "account_wasm.js",
6
+ "types": "account_wasm.d.ts",
7
+ "repository": "https://github.com/cartridge-gg/controller-rs",
8
+ "license": "MIT"
9
+ }
@@ -0,0 +1,13 @@
1
+ function releaseStub() {}
2
+
3
+ export class Mutex {
4
+ lastPromise = Promise.resolve();
5
+
6
+ async obtain() {
7
+ let release = releaseStub;
8
+ const lastPromise = this.lastPromise;
9
+ this.lastPromise = new Promise((resolve) => (release = resolve));
10
+ await lastPromise;
11
+ return release;
12
+ }
13
+ }