Skip to content

Commit

Permalink
Merge pull request #22 from multiversx/hw-06
Browse files Browse the repository at this point in the history
Update examples wrt. new signing providers
  • Loading branch information
andreibancioiu authored May 8, 2023
2 parents 43535e4 + f2b2d9c commit 8a1f4f0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 29 deletions.
36 changes: 22 additions & 14 deletions signing-providers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions signing-providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@multiversx/sdk-wallet": "4.0.0",
"@multiversx/sdk-core": "12.1.0",
"@multiversx/sdk-extension-provider": "2.0.7",
"@multiversx/sdk-hw-provider": "5.0.0",
"@multiversx/sdk-web-wallet-provider": "2.3.0",
"@multiversx/sdk-hw-provider": "6.0.0",
"@multiversx/sdk-web-wallet-provider": "3.0.0",
"@multiversx/sdk-wallet-connect-provider": "3.2.1",
"qrcode": "1.5.1",
"qs": "6.10.3"
Expand Down
16 changes: 8 additions & 8 deletions signing-providers/src/hw.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class HW {
chainID: "T"
});

await this.provider.signTransaction(transaction);
const signedTransaction = await this.provider.signTransaction(transaction);

this.displayOutcome("Transaction signed.", transaction.toSendable());
this.displayOutcome("Transaction signed.", signedTransaction.toSendable());
}

async signTransactions() {
Expand Down Expand Up @@ -101,9 +101,9 @@ export class HW {
});

const transactions = [firstTransaction, secondTransaction];
await this.provider.signTransactions(transactions);
const signedTransactions = await this.provider.signTransactions(transactions);

this.displayOutcome("Transactions signed.", transactions.map((transaction) => transaction.toSendable()));
this.displayOutcome("Transactions signed.", signedTransactions.map((transaction) => transaction.toSendable()));
}

async signGuardedTransaction() {
Expand Down Expand Up @@ -133,9 +133,9 @@ export class HW {
})
});

await this.provider.signTransaction(transaction);
const signedTransaction = await this.provider.signTransaction(transaction);

this.displayOutcome("Transaction signed.", transaction.toSendable());
this.displayOutcome("Transaction signed.", signedTransaction.toSendable());
}

async signMessage() {
Expand All @@ -145,9 +145,9 @@ export class HW {
message: Buffer.from("hello")
});

await this.provider.signMessage(message);
const signedMessage = await this.provider.signMessage(message);

this.displayOutcome("Message signed.", message);
this.displayOutcome("Message signed.", signedMessage);
}

displayOutcome(message, outcome) {
Expand Down
18 changes: 13 additions & 5 deletions signing-providers/src/web-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,35 @@ export class WebWallet {

async signTransaction() {
const sender = getUrlParams().address;
if (!sender) {
alert("Try to login first.");
return;
}

const transaction = new Transaction({
nonce: 42,
value: "1",
value: "1000000000000000000",
sender: new Address(sender),
receiver: new Address("erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa"),
gasPrice: 1000000000,
gasLimit: 50000,
data: new TransactionPayload(),
chainID: "T",
version: 1
chainID: "T"
});

await this.provider.signTransaction(transaction);
}

async signTransactions() {
const sender = getUrlParams().address;
if (!sender) {
alert("Try to login first.");
return;
}

const firstTransaction = new Transaction({
nonce: 42,
value: "1",
value: "1000000000000000000",
gasLimit: 70000,
sender: new Address(sender),
receiver: new Address("erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa"),
Expand All @@ -75,7 +83,7 @@ export class WebWallet {

const secondTransaction = new Transaction({
nonce: 43,
value: "1",
value: "3000000000000000000",
gasLimit: 70000,
sender: new Address(sender),
receiver: new Address("erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa"),
Expand Down

0 comments on commit 8a1f4f0

Please sign in to comment.