Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions wasmjs/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as Core from "craminiumlab-wallet-core";
import { TW } from "craminiumlab-wallet-core";
import { WalletCore, initWasm } from "craminiumlab-wallet-core";
export { initWasm };
export declare class WalletCoreWrapper {
CoinType: WalletCore["CoinType"];
HexCoding: WalletCore["HexCoding"];
AnySigner: WalletCore["AnySigner"];
TransactionCompiler: WalletCore["TransactionCompiler"];
DataVector: WalletCore["DataVector"];
PrivateKey: WalletCore["PrivateKey"];
TW: typeof TW;
constructor(core: WalletCore, _tw?: typeof Core.TW);
static init(): Promise<WalletCoreWrapper>;
encodeHex(data: Uint8Array): string;
createWithData(hexStr: string): Uint8Array;
anySign(input: Uint8Array, coin: InstanceType<WalletCore["CoinType"]>): Uint8Array;
preImageHashes(coin: InstanceType<WalletCore["CoinType"]>, txInput: Uint8Array): Uint8Array;
compileWithSignatures(coinType: InstanceType<WalletCore["CoinType"]>, txInputData: Uint8Array, signatures: string[], publicKeys: string[]): Uint8Array;
makeDataVector(items: Uint8Array[]): ReturnType<WalletCore["DataVector"]["create"]>;
buildAptosUnsignedTx(jsonStr: string): Uint8Array;
buildAptosUnsignedMessage(txInput: Uint8Array): Uint8Array;
buildCardanoUnsignedTx(jsonStr: string): Uint8Array;
buildCardanoUnsignedMessage(txInput: Uint8Array): Uint8Array;
buildCosmosUnsignedTx(jsonStr: string): Uint8Array;
buildCosmosUnsignedMessage(txInput: Uint8Array): Uint8Array;
buildNearUnsignedTx(jsonStr: string): Uint8Array;
buildNearUnsignedMessage(txInput: Uint8Array): Uint8Array;
buildStellarUnsignedTx(jsonStr: string): Uint8Array;
buildStellarUnsignedMessage(txInput: Uint8Array): Uint8Array;
buildEVMUnsignedTx(jsonStr: string): Uint8Array;
buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array;
marshalInput(input: protobuf.Writer): Uint8Array;
}
30 changes: 24 additions & 6 deletions wasmjs/dist/src/index.js → wasmjs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class WalletCoreWrapper {
}
preImageHashes(coin, txInput) {
const result = this.TransactionCompiler.preImageHashes(coin, txInput);
console.log('RESULT', result, result.length);
return result;
}
compileWithSignatures(coinType, txInputData, signatures, publicKeys) {
Expand Down Expand Up @@ -98,7 +97,6 @@ export class WalletCoreWrapper {
}
buildCosmosUnsignedTx(jsonStr) {
const req = JSON.parse(jsonStr);
console.log(req);
const message = this.TW.Cosmos.Proto.Message.create({
sendCoinsMessage: this.TW.Cosmos.Proto.Message.Send.create({
fromAddress: req.fromAddress,
Expand Down Expand Up @@ -137,7 +135,6 @@ export class WalletCoreWrapper {
}
buildNearUnsignedTx(jsonStr) {
const req = JSON.parse(jsonStr);
console.log(req);
const action = this.TW.NEAR.Proto.Action.create({
transfer: this.TW.NEAR.Proto.Transfer.create({
deposit: this.HexCoding.decode(req.transferAmount)
Expand All @@ -151,7 +148,6 @@ export class WalletCoreWrapper {
actions: [action],
publicKey: this.HexCoding.decode(req.publicKey),
};
console.log(input);
return this.TW.NEAR.Proto.SigningInput.encode(input).finish();
}
buildNearUnsignedMessage(txInput) {
Expand All @@ -161,7 +157,6 @@ export class WalletCoreWrapper {
}
buildStellarUnsignedTx(jsonStr) {
const req = JSON.parse(jsonStr);
console.log(req);
const opPayment = TW.Stellar.Proto.OperationPayment.create({
destination: req.destination,
amount: Long.fromString(String(req.amount)),
Expand All @@ -177,14 +172,37 @@ export class WalletCoreWrapper {
opPayment: opPayment,
memoText: memoText
};
console.log(input);
return this.TW.Stellar.Proto.SigningInput.encode(input).finish();
}
buildStellarUnsignedMessage(txInput) {
const preimage = this.preImageHashes(this.CoinType.stellar, txInput);
const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage);
return out.dataHash;
}
buildEVMUnsignedTx(jsonStr) {
const req = JSON.parse(jsonStr);
const opPayment = TW.Stellar.Proto.OperationPayment.create({
destination: req.destination,
amount: Long.fromString(String(req.amount)),
});
const memoText = this.TW.Stellar.Proto.MemoText.create({
text: req.memoText
});
const input = {
fee: req.fee,
account: req.account,
passphrase: 'Public Global Stellar Network ; September 2015',
sequence: Long.fromString(String(req.sequence)),
opPayment: opPayment,
memoText: memoText
};
return this.TW.Stellar.Proto.SigningInput.encode(input).finish();
}
buildEVMUnsignedMessage(txInput) {
const preimage = this.preImageHashes(this.CoinType.stellar, txInput);
const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage);
return out.dataHash;
}
marshalInput(input) {
return input.finish();
}
Expand Down
121 changes: 0 additions & 121 deletions wasmjs/dist/test/tw.test.js

This file was deleted.

5 changes: 3 additions & 2 deletions wasmjs/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "craminiumlab-wasmjs",
"version": "1.0.0",
"version": "1.0.4",
"description": "",
"main": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc",
Expand Down
2 changes: 0 additions & 2 deletions wasmjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,4 @@ export class WalletCoreWrapper {
marshalInput(input: protobuf.Writer): Uint8Array {
return input.finish();
}


}
11 changes: 6 additions & 5 deletions wasmjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Bundler", // or "NodeNext"
"target": "ES2020",
"moduleResolution": "node",
"outDir": "dist",
"declaration": true,
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist",
"skipLibCheck": true
},
"include": ["src", "test"]
"include": ["src/**/*"]
}
Loading