Connecting to AlgoSigner is not effected by the transition
AlgoSigner.connect()
.catch(e => console.error(e));
AlgoSigner.connect()
.catch(e => console.error(e));
response
The algosdk client setup is not effected by the transition
const algodServer = 'https://testnet-algorand.api.purestake.io/ps2';
const token = { 'X-API-Key': 'YOUR API KEY HERE' };
algodClient = new algosdk.Algodv2(token, algodServer, '');
algodClient.status().do()
.then(d => console.log(d['last-round']))
.catch(e => console.error(e));
const algodServer = 'https://testnet-algorand.api.purestake.io/ps2';
const token = { 'X-API-Key': 'YOUR API KEY HERE' };
algodClient = new algosdk.Algodv2(token, algodServer, '');
algodClient.status().do()
.then(d => console.log(d['last-round']))
.catch(e => console.error(e));
response
Retrieval of user accounts is not effected by the transition
AlgoSigner.accounts({ ledger: 'TestNet' })
.then(d => accounts = d)
.catch(e => console.error(e));
AlgoSigner.accounts({ ledger: 'TestNet' })
.then(d => accounts = d)
.catch(e => console.error(e));
response
There is a change in the way paramaters are expected to be obtained
AlgoSigner.algod({
ledger: 'TestNet',
path: '/v2/transactions/params'
})
.then(d => txParams = d)
.catch(e => console.error(e));
algodClient.getTransactionParams().do()
.then(d => txParamsJS = d)
.catch(e => console.error(e));
response
There are several notable differences in the signing functionality
AlgoSigner.sign({
from: document.getElementById('from').value,
to: document.getElementById('to').value,
amount: +document.getElementById('amount').value,
note: document.getElementById('note').value,
type: 'pay',
fee: txParams['min-fee'],
firstRound: txParams['last-round'],
lastRound: txParams['last-round'] + 1000,
genesisID: txParams['genesis-id'],
genesisHash: txParams['genesis-hash'],
flatFee: true
})
.then(d => signedTx = d)
.catch(e => console.error(e));
const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: document.getElementById('from').value,
to: document.getElementById('to').value,
amount: +document.getElementById('amount').value,
note: AlgoSigner.encoding.stringToByteArray(document.getElementById('note').value),
suggestedParams: {...txParamsJS}
});
// Use the AlgoSigner encoding library to make the transactions base64
let txn_b64 = AlgoSigner.encoding.msgpackToBase64(txn.toByte());
AlgoSigner.signTxn([{txn: txn_b64}])
.then(d => signedTxs = d)
.catch(e => console.error(e));
response
Send transaction is mostly the same, with one exception.
AlgoSigner.send({
ledger: 'TestNet',
tx: signedTx.blob
})
.then(d => tx = d)
.catch(e => console.error(e));
AlgoSigner.send({
ledger: 'TestNet',
tx: signedTxs[0].blob
})
.then(d => tx = d)
.catch(e => console.error(e));
response