Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
version: VERSION,
toAddr,
amount: units.toQa(amount, units.Units.Zil),
gasPrice: new BN(minGasPriceInQa),
gasLimit: Long.fromNumber(1),
pubKey: publicKey,
nonce
},
provider
);
const signedTx = yield wallet.sign(tx);
const { txParams } = signedTx;
// Send a transaction to the network
const data = yield provider.send(RPCMethod.CreateTransaction, txParams);
if (data.error !== undefined) {
throw Error(data.error.message);
}
const sendTxId = data.result.TranID;
yield put({
type: consts.SEND_TX_SUCCEEDED,
payload: { sendTxId }
});
} catch (error) {
console.log(error);
yield put({ type: consts.SEND_TX_FAILED });
}
}
{
version: VERSION,
toAddr,
amount,
gasPrice,
gasLimit,
pubKey,
nonce
},
provider
);
const signedTx = await wallet.sign(tx);
const { txParams } = signedTx;
// Send a transaction to the network
const tsRes = await provider.send(RPCMethod.CreateTransaction, txParams);
const { result } = tsRes;
const txId = result && result.TranID;
if (txId === undefined) {
console.log('Response', tsRes);
throw Error('No TxID!');
}
console.log(`TxID: ${txId}`);
const now = Date.now();
const userData = {
claimed_at: now
};
await userRef.set(userData);
console.log(`Claimed at: ${now}`);
public send = async ({ args }): Promise => {
const { amount, toAddress } = args;
const { wallet } = this.state;
const tx = new Transaction(await this.getParams(toAddress, amount), provider);
const signedTx = await wallet.sign(tx);
const { txParams } = signedTx;
// Send a transaction to the network
const res = await provider.send(RPCMethod.CreateTransaction, txParams);
if (res.error !== undefined) throw new Error(res.error.message);
return res.result ? res.result.TranID : undefined;
};
async signedTxSend(payload) {
const tx = await this.provider.send( // Send to shard node.
RPCMethod.CreateTransaction, payload
);
return tx;
}
const zilTxData = this.transactions.new({
nonce,
gasPrice,
amount,
gasLimit,
version,
toAddr,
pubKey,
code,
data
});
// Sign transaction by current account. //
const { txParams } = await this.wallet.sign(zilTxData);
return await this.provider.send( // Send to shard node.
RPCMethod.CreateTransaction, txParams
);
}
constructor(provider: Provider, signer: Wallet) {
this.provider = provider;
this.provider.middleware.request.use(
util.formatOutgoingTx,
RPCMethod.CreateTransaction,
);
this.signer = signer;
}
constructor(provider: Provider, signer: Wallet) {
this.provider = provider;
this.provider.middleware.request.use(
formatOutgoingTx,
RPCMethod.CreateTransaction,
);
this.signer = signer;
}
async createTransaction(
tx: Transaction,
maxAttempts: number = GET_TX_ATTEMPTS,
interval: number = 1000,
blockConfirm: boolean = false,
): Promise {
try {
const response = await this.provider.send(RPCMethod.CreateTransaction, {
...tx.txParams,
priority: tx.toDS,
});
if (response.error) {
throw response.error;
}
if (blockConfirm) {
return tx.blockConfirm(response.result.TranID, maxAttempts, interval);
}
return tx.confirm(response.result.TranID, maxAttempts, interval);
} catch (err) {
throw err;
}
}
constructor(provider: Provider, signer: Wallet) {
this.provider = provider;
this.provider.middleware.request.use(
util.formatOutgoingTx,
RPCMethod.CreateTransaction,
);
this.signer = signer;
}
signedTxSend(payload) {
return this.provider.send(
RPCMethod.CreateTransaction, payload
)
}