Skip to content

Commit

Permalink
Account wasm use pending block
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Aug 30, 2024
1 parent bea1576 commit 864a577
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 50 deletions.
21 changes: 13 additions & 8 deletions packages/account-wasm/pkg/account_wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ export interface JsCall {
calldata: Felt[];
}

export interface JsEstimateFeeDetails {
export interface JsInvocationsDetails {
nonce: Felt;
maxFee: Felt;
}

export interface JsPolicy {
target: string;
method: string;
}

export type Felts = JsFelt[];
Expand All @@ -24,9 +30,8 @@ export interface JsCredentials {
privateKey: Felt;
}

export interface JsInvocationsDetails {
export interface JsEstimateFeeDetails {
nonce: Felt;
maxFee: Felt;
}

export interface JsOutsideExecution {
Expand All @@ -37,11 +42,6 @@ export interface JsOutsideExecution {
nonce: Felt;
}

export interface JsPolicy {
target: string;
method: string;
}

/**
*/
export class CartridgeAccount {
Expand Down Expand Up @@ -167,4 +167,9 @@ export class CartridgeSessionAccount {
* @returns {Promise<any>}
*/
execute(calls: (JsCall)[]): Promise<any>;
/**
* @param {(JsCall)[]} calls
* @returns {Promise<any>}
*/
execute_from_outside(calls: (JsCall)[]): Promise<any>;
}
88 changes: 49 additions & 39 deletions packages/account-wasm/pkg/account_wasm_bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ function addHeapObject(obj) {
return idx;
}

const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;

let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });

cachedTextDecoder.decode();
let WASM_VECTOR_LEN = 0;

let cachedUint8Memory0 = null;

Expand All @@ -48,13 +44,6 @@ function getUint8Memory0() {
return cachedUint8Memory0;
}

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}

let WASM_VECTOR_LEN = 0;

const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;

let cachedTextEncoder = new lTextEncoder('utf-8');
Expand Down Expand Up @@ -111,6 +100,10 @@ function passStringToWasm0(arg, malloc, realloc) {
return ptr;
}

function isLikeNone(x) {
return x === undefined || x === null;
}

let cachedInt32Memory0 = null;

function getInt32Memory0() {
Expand All @@ -120,8 +113,15 @@ function getInt32Memory0() {
return cachedInt32Memory0;
}

function isLikeNone(x) {
return x === undefined || x === null;
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;

let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });

cachedTextDecoder.decode();

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}

let cachedFloat64Memory0 = null;
Expand Down Expand Up @@ -229,7 +229,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
return real;
}
function __wbg_adapter_42(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18209be10352b66c(arg0, arg1, addHeapObject(arg2));
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hba4fb360f5c4ef7b(arg0, arg1, addHeapObject(arg2));
}

let cachedUint32Memory0 = null;
Expand Down Expand Up @@ -258,8 +258,8 @@ function handleError(f, args) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
}
function __wbg_adapter_164(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h09491c54862df783(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
function __wbg_adapter_165(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h0e740cd798a04611(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}

const CartridgeAccountFinalization = (typeof FinalizationRegistry === 'undefined')
Expand Down Expand Up @@ -583,6 +583,16 @@ export class CartridgeSessionAccount {
const ret = wasm.cartridgesessionaccount_execute(this.__wbg_ptr, ptr0, len0);
return takeObject(ret);
}
/**
* @param {(JsCall)[]} calls
* @returns {Promise<any>}
*/
execute_from_outside(calls) {
const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.cartridgesessionaccount_execute_from_outside(this.__wbg_ptr, ptr0, len0);
return takeObject(ret);
}
}

export function __wbindgen_object_drop_ref(arg0) {
Expand All @@ -594,6 +604,25 @@ export function __wbindgen_object_clone_ref(arg0) {
return addHeapObject(ret);
};

export function __wbindgen_string_get(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};

export function __wbindgen_error_new(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};

export function __wbindgen_string_new(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

export function __wbindgen_json_parse(arg0, arg1) {
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand All @@ -608,11 +637,6 @@ export function __wbindgen_json_serialize(arg0, arg1) {
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};

export function __wbindgen_error_new(arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};

export function __wbindgen_is_undefined(arg0) {
const ret = getObject(arg0) === undefined;
return ret;
Expand All @@ -631,15 +655,6 @@ export function __wbindgen_number_get(arg0, arg1) {
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
};

export function __wbindgen_string_get(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};

export function __wbindgen_is_object(arg0) {
const val = getObject(arg0);
const ret = typeof(val) === 'object' && val !== null;
Expand All @@ -651,11 +666,6 @@ export function __wbindgen_bigint_from_u64(arg0) {
return addHeapObject(ret);
};

export function __wbindgen_string_new(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

export function __wbindgen_jsval_loose_eq(arg0, arg1) {
const ret = getObject(arg0) == getObject(arg1);
return ret;
Expand Down Expand Up @@ -997,7 +1007,7 @@ export function __wbg_new_81740750da40724f(arg0, arg1) {
const a = state0.a;
state0.a = 0;
try {
return __wbg_adapter_164(a, state0.b, arg0, arg1);
return __wbg_adapter_165(a, state0.b, arg0, arg1);
} finally {
state0.a = a;
}
Expand Down Expand Up @@ -1101,8 +1111,8 @@ export function __wbindgen_memory() {
return addHeapObject(ret);
};

export function __wbindgen_closure_wrapper2360(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 509, __wbg_adapter_42);
export function __wbindgen_closure_wrapper2392(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 516, __wbg_adapter_42);
return addHeapObject(ret);
};

Binary file modified packages/account-wasm/pkg/account_wasm_bg.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions packages/account-wasm/pkg/account_wasm_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ export function cartridgesessionaccount_new(a: number, b: number, c: number, d:
export function cartridgesessionaccount_new_as_registered(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void;
export function cartridgesessionaccount_sign(a: number, b: number, c: number, d: number): number;
export function cartridgesessionaccount_execute(a: number, b: number, c: number): number;
export function cartridgesessionaccount_execute_from_outside(a: number, b: number, c: number): number;
export function __wbindgen_malloc(a: number, b: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
export const __wbindgen_export_2: WebAssembly.Table;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18209be10352b66c(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hba4fb360f5c4ef7b(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
export function __wbindgen_exn_store(a: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h09491c54862df783(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h0e740cd798a04611(a: number, b: number, c: number, d: number): void;
2 changes: 1 addition & 1 deletion packages/account_sdk/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
signer,
address,
chain_id,
block_id: BlockId::Tag(BlockTag::Latest),
block_id: BlockId::Tag(BlockTag::Pending),
guardian,
}
}
Expand Down

0 comments on commit 864a577

Please sign in to comment.