kit-squared 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/library/connection.js +3 -3
- package/dist/library/program.d.ts +1 -39
- package/dist/library/program.js +2 -74
- package/dist/library/transaction.d.ts +52 -0
- package/dist/library/transaction.js +173 -0
- package/dist/library/wallet.js +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { type NetworkType } from "./library/wallet.js";
|
|
|
2
2
|
export declare function init(http: string, ws: string, networkType?: NetworkType): void;
|
|
3
3
|
export { getNetworkType, getNetwork, getConnection, checkAccountExists, getAccountBalance } from "./library/connection.js";
|
|
4
4
|
export { onConnect, onDisconnect } from "./library/connectSchedule.js";
|
|
5
|
-
export {
|
|
5
|
+
export { clearAddedAccounts, addAccounts, getAddedAccounts, createProgram, } from "./library/program.js";
|
|
6
|
+
export { transacting, TRANSACTION_STATE, transactionState, onTransaction, transact, simulate, type Simulation, type SimulationError, } from "./library/transaction.ts";
|
|
6
7
|
export * from "./library/utils.js";
|
|
7
8
|
export { walletState, walletInitial, walletConnecting, walletConnected, walletError, signer, myKey, me, myKeyString, isMe, getStoredWalletSelection, disconnectWallet, unmountWallet } from "./library/wallet.js";
|
|
8
9
|
export { availableWallets, selection, selectWallet, getWalletInfo, unmountTeardown, recheckWallets, } from "./library/walletSelection.js";
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,8 @@ export function init(http, ws, networkType) {
|
|
|
8
8
|
}
|
|
9
9
|
export { getNetworkType, getNetwork, getConnection, checkAccountExists, getAccountBalance } from "./library/connection.js";
|
|
10
10
|
export { onConnect, onDisconnect } from "./library/connectSchedule.js";
|
|
11
|
-
export {
|
|
11
|
+
export { clearAddedAccounts, addAccounts, getAddedAccounts, createProgram, } from "./library/program.js";
|
|
12
|
+
export { transacting, TRANSACTION_STATE, transactionState, onTransaction, transact, simulate, } from "./library/transaction.js";
|
|
12
13
|
export * from "./library/utils.js";
|
|
13
14
|
export { walletState, walletInitial, walletConnecting, walletConnected, walletError, signer, myKey, me, myKeyString, isMe, getStoredWalletSelection, disconnectWallet, unmountWallet } from "./library/wallet.js";
|
|
14
15
|
export { availableWallets, selection, selectWallet, getWalletInfo, unmountTeardown, recheckWallets, } from "./library/walletSelection.js";
|
|
@@ -37,7 +37,9 @@ function _connect() {
|
|
|
37
37
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send({ abortSignal });
|
|
38
38
|
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (message) => setTransactionMessageFeePayerSigner(feePayer, message), (message) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, message), (message) => appendTransactionMessageInstructions(instructions, message));
|
|
39
39
|
assertIsTransactionMessageWithSingleSendingSigner(transactionMessage);
|
|
40
|
+
console.log("AA1");
|
|
40
41
|
const signatureBytes = await signAndSendTransactionMessageWithSigners(transactionMessage);
|
|
42
|
+
console.log("AAB");
|
|
41
43
|
const signature = signatureBytesToBase58String(signatureBytes);
|
|
42
44
|
return signature;
|
|
43
45
|
};
|
|
@@ -58,12 +60,10 @@ export function getConnection() {
|
|
|
58
60
|
throw new Error("Network not configured (you must call setNetwork before this point).");
|
|
59
61
|
return _connect();
|
|
60
62
|
}
|
|
61
|
-
// !!! TODO
|
|
62
63
|
export async function checkAccountExists(address) {
|
|
63
|
-
// return true;
|
|
64
|
-
//todo: this
|
|
65
64
|
return await getAccountBalance(address) > 0n;
|
|
66
65
|
}
|
|
67
66
|
export async function getAccountBalance(address) {
|
|
67
|
+
//@ts-ignore
|
|
68
68
|
return await (await getConnection().getLamportBalance(address)).value;
|
|
69
69
|
}
|
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type Address, type Instruction } from "@solana/kit";
|
|
1
|
+
import { type Address } from "@solana/kit";
|
|
3
2
|
import type { TransactionSendingSigner } from "@solana/signers";
|
|
4
|
-
export declare let _transacting: boolean;
|
|
5
|
-
export declare let transacting: import("svelte/store").Writable<boolean>;
|
|
6
|
-
export declare const TRANSACTION_STATE: {
|
|
7
|
-
INITIAL: string;
|
|
8
|
-
REQUESTED: string;
|
|
9
|
-
PENDING: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const transactionState: import("svelte/store").Writable<string>;
|
|
12
|
-
export declare const onTransaction: {
|
|
13
|
-
request: {
|
|
14
|
-
(callback: Callback): () => void;
|
|
15
|
-
trigger: (...args: any[]) => Promise<void>;
|
|
16
|
-
killAll: () => void;
|
|
17
|
-
};
|
|
18
|
-
submit: {
|
|
19
|
-
(callback: Callback): () => void;
|
|
20
|
-
trigger: (...args: any[]) => Promise<void>;
|
|
21
|
-
killAll: () => void;
|
|
22
|
-
};
|
|
23
|
-
confirm: {
|
|
24
|
-
(callback: Callback): () => void;
|
|
25
|
-
trigger: (...args: any[]) => Promise<void>;
|
|
26
|
-
killAll: () => void;
|
|
27
|
-
};
|
|
28
|
-
cancel: {
|
|
29
|
-
(callback: Callback): () => void;
|
|
30
|
-
trigger: (...args: any[]) => Promise<void>;
|
|
31
|
-
killAll: () => void;
|
|
32
|
-
};
|
|
33
|
-
fail: {
|
|
34
|
-
(callback: Callback): () => void;
|
|
35
|
-
trigger: (...args: any[]) => Promise<void>;
|
|
36
|
-
killAll: () => void;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
3
|
export declare function clearAddedAccounts(): void;
|
|
40
4
|
export declare function addAccounts(accounts: {
|
|
41
5
|
[key: string]: Address;
|
|
@@ -43,8 +7,6 @@ export declare function addAccounts(accounts: {
|
|
|
43
7
|
export declare function getAddedAccounts(): {
|
|
44
8
|
[key: string]: Address;
|
|
45
9
|
};
|
|
46
|
-
export declare function transact(ixs?: Instruction[], names?: string[]): Promise<void>;
|
|
47
|
-
export declare function transactSingle(ix: Instruction, name?: string | null): Promise<void>;
|
|
48
10
|
export declare function createProgram(programClient: {
|
|
49
11
|
[key: string]: any;
|
|
50
12
|
}, idl: {
|
package/dist/library/program.js
CHANGED
|
@@ -4,35 +4,9 @@ import { Event } from "./utils.js";
|
|
|
4
4
|
import { signer } from "./wallet.js";
|
|
5
5
|
import { getConnection } from "./connection.js";
|
|
6
6
|
import { typeEncoder } from "./utils.js";
|
|
7
|
-
import { fetchEncodedAccount, getBase64Codec } from "@solana/kit";
|
|
7
|
+
import { appendTransactionMessageInstructions, assertIsTransactionMessageWithSingleSendingSigner, createTransactionMessage, fetchEncodedAccount, getBase64Codec, getBase64EncodedWireTransaction, getBase64Encoder, getTransactionEncoder, partiallySignTransactionMessageWithSigners, partiallySignTransactionWithSigners, pipe, sequentialInstructionPlan, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, signTransactionMessageWithSigners, singleInstructionPlan } from "@solana/kit";
|
|
8
8
|
import {} from "@solana/kit";
|
|
9
|
-
|
|
10
|
-
export let transacting = writable(_transacting);
|
|
11
|
-
function _setTransacting(state) {
|
|
12
|
-
_transacting = state !== TRANSACTION_STATE.INITIAL;
|
|
13
|
-
transacting.set(_transacting);
|
|
14
|
-
}
|
|
15
|
-
export const TRANSACTION_STATE = {
|
|
16
|
-
INITIAL: "INITIAL",
|
|
17
|
-
REQUESTED: "REQUESTED",
|
|
18
|
-
PENDING: "PENDING",
|
|
19
|
-
};
|
|
20
|
-
const INITIAL = TRANSACTION_STATE.INITIAL;
|
|
21
|
-
const REQUESTED = TRANSACTION_STATE.REQUESTED;
|
|
22
|
-
const PENDING = TRANSACTION_STATE.PENDING;
|
|
23
|
-
export const transactionState = writable(TRANSACTION_STATE.INITIAL);
|
|
24
|
-
const onRequest = Event();
|
|
25
|
-
const onSubmit = Event();
|
|
26
|
-
const onConfirm = Event();
|
|
27
|
-
const onCancel = Event();
|
|
28
|
-
const onFail = Event();
|
|
29
|
-
export const onTransaction = {
|
|
30
|
-
request: onRequest,
|
|
31
|
-
submit: onSubmit,
|
|
32
|
-
confirm: onConfirm,
|
|
33
|
-
cancel: onCancel,
|
|
34
|
-
fail: onFail,
|
|
35
|
-
};
|
|
9
|
+
import { transactSingle } from "./transaction.js";
|
|
36
10
|
let addedAccounts = {};
|
|
37
11
|
export function clearAddedAccounts() {
|
|
38
12
|
addedAccounts = {};
|
|
@@ -45,52 +19,6 @@ export function addAccounts(accounts) {
|
|
|
45
19
|
export function getAddedAccounts() {
|
|
46
20
|
return addedAccounts;
|
|
47
21
|
}
|
|
48
|
-
function _txWasCancelled(e) {
|
|
49
|
-
let msg;
|
|
50
|
-
if (e.message) {
|
|
51
|
-
msg = e.message.toLowerCase();
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
msg = e.toString().toLowerCase();
|
|
55
|
-
}
|
|
56
|
-
return msg.includes('denied') || msg.includes('rejected') || msg.includes('cancelled');
|
|
57
|
-
}
|
|
58
|
-
export async function transact(ixs = [], names = []) {
|
|
59
|
-
_setTransacting(REQUESTED);
|
|
60
|
-
onRequest.trigger(names);
|
|
61
|
-
const connection = getConnection();
|
|
62
|
-
try {
|
|
63
|
-
const signature = await connection.sendTransactionFromInstructionsWithWalletApp({
|
|
64
|
-
feePayer: signer,
|
|
65
|
-
instructions: ixs
|
|
66
|
-
});
|
|
67
|
-
_setTransacting(PENDING);
|
|
68
|
-
onSubmit.trigger(names);
|
|
69
|
-
// Set up an abort controller.
|
|
70
|
-
const abortController = new AbortController();
|
|
71
|
-
const confirmed = await connection.getRecentSignatureConfirmation({
|
|
72
|
-
abortSignal: abortController.signal,
|
|
73
|
-
commitment: 'confirmed',
|
|
74
|
-
signature: signature
|
|
75
|
-
});
|
|
76
|
-
_setTransacting(INITIAL);
|
|
77
|
-
onConfirm.trigger(names);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
if (_txWasCancelled(e)) {
|
|
81
|
-
// TODO: properly catch this and other errors
|
|
82
|
-
onCancel.trigger(names);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
onFail.trigger(names);
|
|
86
|
-
}
|
|
87
|
-
_setTransacting(INITIAL);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export async function transactSingle(ix, name = null) {
|
|
91
|
-
let names = name ? [name] : [];
|
|
92
|
-
return await transact([ix], names);
|
|
93
|
-
}
|
|
94
22
|
export async function createProgram(programClient, idl, signer = null, noEvents = false) {
|
|
95
23
|
if (!programClient) {
|
|
96
24
|
throw new Error("Missing program client.");
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Instruction } from "@solana/kit";
|
|
2
|
+
export declare let _transacting: boolean;
|
|
3
|
+
export declare let transacting: import("svelte/store").Writable<boolean>;
|
|
4
|
+
export declare const TRANSACTION_STATE: {
|
|
5
|
+
INITIAL: string;
|
|
6
|
+
REQUESTED: string;
|
|
7
|
+
PENDING: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const transactionState: import("svelte/store").Writable<string>;
|
|
10
|
+
export declare const onTransaction: {
|
|
11
|
+
request: {
|
|
12
|
+
(callback: import("./utils.ts").Callback): () => void;
|
|
13
|
+
trigger: (...args: any[]) => Promise<void>;
|
|
14
|
+
killAll: () => void;
|
|
15
|
+
};
|
|
16
|
+
submit: {
|
|
17
|
+
(callback: import("./utils.ts").Callback): () => void;
|
|
18
|
+
trigger: (...args: any[]) => Promise<void>;
|
|
19
|
+
killAll: () => void;
|
|
20
|
+
};
|
|
21
|
+
confirm: {
|
|
22
|
+
(callback: import("./utils.ts").Callback): () => void;
|
|
23
|
+
trigger: (...args: any[]) => Promise<void>;
|
|
24
|
+
killAll: () => void;
|
|
25
|
+
};
|
|
26
|
+
cancel: {
|
|
27
|
+
(callback: import("./utils.ts").Callback): () => void;
|
|
28
|
+
trigger: (...args: any[]) => Promise<void>;
|
|
29
|
+
killAll: () => void;
|
|
30
|
+
};
|
|
31
|
+
fail: {
|
|
32
|
+
(callback: import("./utils.ts").Callback): () => void;
|
|
33
|
+
trigger: (...args: any[]) => Promise<void>;
|
|
34
|
+
killAll: () => void;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type Simulation = {
|
|
38
|
+
result: any;
|
|
39
|
+
success: boolean;
|
|
40
|
+
error: null | SimulationError;
|
|
41
|
+
};
|
|
42
|
+
export type SimulationError = {
|
|
43
|
+
instruction: string;
|
|
44
|
+
type: string;
|
|
45
|
+
code: string;
|
|
46
|
+
number: number;
|
|
47
|
+
label: string;
|
|
48
|
+
anchorErrorLog: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function simulate(ixs?: Instruction[]): Promise<Simulation>;
|
|
51
|
+
export declare function transact(ixs?: Instruction[], names?: string[]): Promise<void>;
|
|
52
|
+
export declare function transactSingle(ix: Instruction, name?: string | null): Promise<void>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
import { Event } from "./utils.js";
|
|
3
|
+
import { signer } from "./wallet.js";
|
|
4
|
+
import { appendTransactionMessageInstructions, assertIsTransactionMessageWithSingleSendingSigner, createTransactionMessage, getBase64EncodedWireTransaction, partiallySignTransactionMessageWithSigners, pipe, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash } from "@solana/kit";
|
|
5
|
+
import { getConnection } from "./connection.js";
|
|
6
|
+
export let _transacting = false;
|
|
7
|
+
export let transacting = writable(_transacting);
|
|
8
|
+
function _setTransacting(state) {
|
|
9
|
+
_transacting = state !== TRANSACTION_STATE.INITIAL;
|
|
10
|
+
transacting.set(_transacting);
|
|
11
|
+
}
|
|
12
|
+
export const TRANSACTION_STATE = {
|
|
13
|
+
INITIAL: "INITIAL",
|
|
14
|
+
REQUESTED: "REQUESTED",
|
|
15
|
+
PENDING: "PENDING",
|
|
16
|
+
};
|
|
17
|
+
const INITIAL = TRANSACTION_STATE.INITIAL;
|
|
18
|
+
const REQUESTED = TRANSACTION_STATE.REQUESTED;
|
|
19
|
+
const PENDING = TRANSACTION_STATE.PENDING;
|
|
20
|
+
export const transactionState = writable(TRANSACTION_STATE.INITIAL);
|
|
21
|
+
const onRequest = Event();
|
|
22
|
+
const onSubmit = Event();
|
|
23
|
+
const onConfirm = Event();
|
|
24
|
+
const onCancel = Event();
|
|
25
|
+
const onFail = Event();
|
|
26
|
+
export const onTransaction = {
|
|
27
|
+
request: onRequest,
|
|
28
|
+
submit: onSubmit,
|
|
29
|
+
confirm: onConfirm,
|
|
30
|
+
cancel: onCancel,
|
|
31
|
+
fail: onFail,
|
|
32
|
+
};
|
|
33
|
+
function _txWasCancelled(e) {
|
|
34
|
+
let msg;
|
|
35
|
+
if (e.message) {
|
|
36
|
+
msg = e.message.toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
msg = e.toString().toLowerCase();
|
|
40
|
+
}
|
|
41
|
+
return msg.includes('denied') || msg.includes('rejected') || msg.includes('cancelled');
|
|
42
|
+
}
|
|
43
|
+
let log = console.log;
|
|
44
|
+
function _parseError(result) {
|
|
45
|
+
const instructionPrefix = "Program log: Instruction: ";
|
|
46
|
+
const errorPrefix = "Program log: AnchorError ";
|
|
47
|
+
const programErrorPrefix = errorPrefix + "thrown";
|
|
48
|
+
const errorCodeFlag = "failed: custom program error: ";
|
|
49
|
+
function _isPrefix(log, prefix) {
|
|
50
|
+
return (log.substring(0, prefix.length) === prefix);
|
|
51
|
+
}
|
|
52
|
+
function _between(str, prefix, suffix) {
|
|
53
|
+
if (!str.includes(prefix) || !str.includes(suffix))
|
|
54
|
+
return "";
|
|
55
|
+
let from = str.indexOf(prefix) + prefix.length;
|
|
56
|
+
let to;
|
|
57
|
+
if (suffix.length === 0) {
|
|
58
|
+
to = str.length;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
to = str.indexOf(suffix);
|
|
62
|
+
}
|
|
63
|
+
return str.substring(from, to);
|
|
64
|
+
}
|
|
65
|
+
let errorType = "anchor";
|
|
66
|
+
let instruction = "";
|
|
67
|
+
let errorNumber = 0;
|
|
68
|
+
let errorMessage = "";
|
|
69
|
+
let errorLabel = "";
|
|
70
|
+
let anchorErrorLog = "";
|
|
71
|
+
let errorCode = "";
|
|
72
|
+
const logs = result.value.logs;
|
|
73
|
+
for (let log of logs) {
|
|
74
|
+
if (_isPrefix(log, instructionPrefix)) {
|
|
75
|
+
instruction = log.substring(instructionPrefix.length);
|
|
76
|
+
}
|
|
77
|
+
else if (_isPrefix(log, errorPrefix)) {
|
|
78
|
+
anchorErrorLog = log;
|
|
79
|
+
if (_isPrefix(log, programErrorPrefix)) {
|
|
80
|
+
errorType = "program";
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
errorType = "anchor";
|
|
84
|
+
//TODO: catch other
|
|
85
|
+
}
|
|
86
|
+
errorNumber = Number(_between(log, "Error Number: ", ". Error Message:"));
|
|
87
|
+
errorMessage = _between(log, " Error Message: ", "");
|
|
88
|
+
errorLabel = _between(log, "Error Code: ", ". Error Number:");
|
|
89
|
+
}
|
|
90
|
+
else if (log.includes(errorCodeFlag)) {
|
|
91
|
+
errorCode = _between(log, errorCodeFlag, "");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
instruction,
|
|
96
|
+
type: errorType,
|
|
97
|
+
code: errorCode,
|
|
98
|
+
number: errorNumber,
|
|
99
|
+
label: errorLabel,
|
|
100
|
+
anchorErrorLog: anchorErrorLog,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export async function simulate(ixs = []) {
|
|
104
|
+
const connection = getConnection();
|
|
105
|
+
const rpc = connection.rpc;
|
|
106
|
+
let simulateTxConfig = {
|
|
107
|
+
commitment: "finalized",
|
|
108
|
+
encoding: "base64",
|
|
109
|
+
replaceRecentBlockhash: true,
|
|
110
|
+
sigVerify: false,
|
|
111
|
+
minContextSlot: undefined,
|
|
112
|
+
innerInstructions: undefined,
|
|
113
|
+
accounts: undefined
|
|
114
|
+
};
|
|
115
|
+
const feePayer = signer;
|
|
116
|
+
// Set up an abort controller.
|
|
117
|
+
const abortController = new AbortController();
|
|
118
|
+
const abortSignal = abortController.signal;
|
|
119
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send({ abortSignal });
|
|
120
|
+
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (message) => setTransactionMessageFeePayerSigner(feePayer, message), (message) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, message), (message) => appendTransactionMessageInstructions(ixs, message));
|
|
121
|
+
assertIsTransactionMessageWithSingleSendingSigner(transactionMessage);
|
|
122
|
+
const partiallySigned = await partiallySignTransactionMessageWithSigners(transactionMessage);
|
|
123
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(partiallySigned);
|
|
124
|
+
let simulateResult = await rpc
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
.simulateTransaction(base64EncodedWireTransaction, simulateTxConfig)
|
|
127
|
+
.send();
|
|
128
|
+
const success = !Boolean(simulateResult?.value?.err);
|
|
129
|
+
const error = success ? null : _parseError(simulateResult);
|
|
130
|
+
return {
|
|
131
|
+
result: simulateResult,
|
|
132
|
+
success,
|
|
133
|
+
error
|
|
134
|
+
};
|
|
135
|
+
console.log(simulateResult);
|
|
136
|
+
}
|
|
137
|
+
export async function transact(ixs = [], names = []) {
|
|
138
|
+
_setTransacting(REQUESTED);
|
|
139
|
+
onRequest.trigger(names);
|
|
140
|
+
const connection = getConnection();
|
|
141
|
+
try {
|
|
142
|
+
const signature = await connection.sendTransactionFromInstructionsWithWalletApp({
|
|
143
|
+
feePayer: signer,
|
|
144
|
+
instructions: ixs
|
|
145
|
+
});
|
|
146
|
+
_setTransacting(PENDING);
|
|
147
|
+
onSubmit.trigger(names);
|
|
148
|
+
// Set up an abort controller.
|
|
149
|
+
const abortController = new AbortController();
|
|
150
|
+
const confirmed = await connection.getRecentSignatureConfirmation({
|
|
151
|
+
abortSignal: abortController.signal,
|
|
152
|
+
commitment: 'confirmed',
|
|
153
|
+
signature: signature
|
|
154
|
+
});
|
|
155
|
+
_setTransacting(INITIAL);
|
|
156
|
+
onConfirm.trigger(names);
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
console.error(e);
|
|
160
|
+
if (_txWasCancelled(e)) {
|
|
161
|
+
// TODO: properly catch this and other errors
|
|
162
|
+
onCancel.trigger(names);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
onFail.trigger(names);
|
|
166
|
+
}
|
|
167
|
+
_setTransacting(INITIAL);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export async function transactSingle(ix, name = null) {
|
|
171
|
+
let names = name ? [name] : [];
|
|
172
|
+
return await transact([ix], names);
|
|
173
|
+
}
|
package/dist/library/wallet.js
CHANGED
|
@@ -20,6 +20,7 @@ const INITIAL = WALLET_STATE.INITIAL;
|
|
|
20
20
|
const CONNECTING = WALLET_STATE.CONNECTING;
|
|
21
21
|
const CONNECTED = WALLET_STATE.CONNECTED;
|
|
22
22
|
const ERROR = WALLET_STATE.ERROR;
|
|
23
|
+
let log = console.log;
|
|
23
24
|
export let walletState = writable(WALLET_STATE.INITIAL);
|
|
24
25
|
function _setWalletState(state) {
|
|
25
26
|
walletState.set(state);
|
|
@@ -160,7 +161,9 @@ function _buildTransactionSendingSigner(_networkType) {
|
|
|
160
161
|
chain,
|
|
161
162
|
account: walletAccount,
|
|
162
163
|
};
|
|
164
|
+
log(111);
|
|
163
165
|
const [{ signature }] = await getAbortablePromise(signAndSendTransactionFeature.signAndSendTransaction(inputWithOptions), abortSignal);
|
|
166
|
+
log(222);
|
|
164
167
|
return Object.freeze([signature]);
|
|
165
168
|
},
|
|
166
169
|
};
|