Skip to content

Commit

Permalink
Extend env (burn, ecrecover)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidenaio committed Feb 16, 2023
1 parent 4b05751 commit 18c5d58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdk-core/assembly/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,10 @@ export namespace env {

@external("env", "balance")
export declare function balance() : usize;

@external("env", "ecrecover")
export declare function ecrecover(data : usize, sig : usize) : usize;

@external("env", "burn")
export declare function burn(amount : usize) : void;
}
10 changes: 10 additions & 0 deletions sdk-core/assembly/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,14 @@ export namespace Host {
models.ProtoStateGlobal.decode
);
}

export function ecrecover(data: Uint8Array, sig: Uint8Array): Bytes {
return util.ptrToBytes(
env.ecrecover(util.bytesToPtr(data), util.bytesToPtr(sig))
);
}

export function burn(amount: Balance): void {
env.burn(util.bytesToPtr(amount.toBytes()));
}
}

0 comments on commit 18c5d58

Please sign in to comment.