forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return signature from sendAndConfirmTransaction (solana-labs#203)
- Loading branch information
Showing
9 changed files
with
31 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 13 additions & 39 deletions
52
token-swap/js/client/util/send-and-confirm-transaction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,21 @@ | ||
// @flow | ||
|
||
import {sendAndConfirmTransaction as realSendAndConfirmTransaction} from '@solana/web3.js'; | ||
import type {Account, Connection, Transaction} from '@solana/web3.js'; | ||
import YAML from 'json-to-pretty-yaml'; | ||
|
||
type TransactionNotification = (string, string) => void; | ||
|
||
let notify: TransactionNotification = () => undefined; | ||
|
||
export function onTransaction(callback: TransactionNotification) { | ||
notify = callback; | ||
} | ||
|
||
export async function sendAndConfirmTransaction( | ||
import type { | ||
Account, | ||
Connection, | ||
Transaction, | ||
TransactionSignature, | ||
} from '@solana/web3.js'; | ||
|
||
export function sendAndConfirmTransaction( | ||
title: string, | ||
connection: Connection, | ||
transaction: Transaction, | ||
...signers: Array<Account> | ||
): Promise<void> { | ||
const when = Date.now(); | ||
|
||
const signature = await realSendAndConfirmTransaction( | ||
connection, | ||
transaction, | ||
signers, | ||
{ | ||
confirmations: 1, | ||
skipPreflight: true, | ||
}, | ||
); | ||
|
||
const body = { | ||
time: new Date(when).toString(), | ||
from: signers[0].publicKey.toBase58(), | ||
signature, | ||
instructions: transaction.instructions.map(i => { | ||
return { | ||
keys: i.keys.map(keyObj => keyObj.pubkey.toBase58()), | ||
programId: i.programId.toBase58(), | ||
data: '0x' + i.data.toString('hex'), | ||
}; | ||
}), | ||
}; | ||
|
||
notify(title, YAML.stringify(body).replace(/"/g, '')); | ||
): Promise<TransactionSignature> { | ||
return realSendAndConfirmTransaction(connection, transaction, signers, { | ||
confirmations: 1, | ||
skipPreflight: true, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,21 @@ | ||
// @flow | ||
|
||
import {sendAndConfirmTransaction as realSendAndConfirmTransaction} from '@solana/web3.js'; | ||
import type {Account, Connection, Transaction} from '@solana/web3.js'; | ||
import YAML from 'json-to-pretty-yaml'; | ||
|
||
type TransactionNotification = (string, string) => void; | ||
|
||
let notify: TransactionNotification = () => undefined; | ||
|
||
export function onTransaction(callback: TransactionNotification) { | ||
notify = callback; | ||
} | ||
|
||
export async function sendAndConfirmTransaction( | ||
import type { | ||
Account, | ||
Connection, | ||
Transaction, | ||
TransactionSignature, | ||
} from '@solana/web3.js'; | ||
|
||
export function sendAndConfirmTransaction( | ||
title: string, | ||
connection: Connection, | ||
transaction: Transaction, | ||
...signers: Array<Account> | ||
): Promise<void> { | ||
const when = Date.now(); | ||
|
||
const signature = await realSendAndConfirmTransaction( | ||
connection, | ||
transaction, | ||
signers, | ||
{ | ||
confirmations: 1, | ||
skipPreflight: true, | ||
}, | ||
); | ||
|
||
const body = { | ||
time: new Date(when).toString(), | ||
from: signers[0].publicKey.toBase58(), | ||
signature, | ||
instructions: transaction.instructions.map(i => { | ||
return { | ||
keys: i.keys.map(keyObj => keyObj.pubkey.toBase58()), | ||
programId: i.programId.toBase58(), | ||
data: '0x' + i.data.toString('hex'), | ||
}; | ||
}), | ||
}; | ||
|
||
notify(title, YAML.stringify(body).replace(/"/g, '')); | ||
): Promise<TransactionSignature> { | ||
return realSendAndConfirmTransaction(connection, transaction, signers, { | ||
confirmations: 1, | ||
skipPreflight: true, | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters