Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API TEAL bytes fix #881

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function main() {
sender: caller.addr,
suggestedParams,
appIndex: appId,
appArgs: [new TextEncoder().encode(now)],
appArgs: [algosdk.coerceToBytes(now)],
});

await algodClient
Expand All @@ -140,9 +140,9 @@ async function main() {
`Raw global state - ${globalState.map((kv) => algosdk.encodeJSON(kv))}`
);

const globalKey = algosdk.base64ToBytes(globalState[0].key);
const globalKey = globalState[0].key;
// show global value
const globalValue = algosdk.base64ToBytes(globalState[0].value.bytes);
const globalValue = globalState[0].value.bytes;

console.log(
`Decoded global state - ${algosdk.bytesToBase64(globalKey)}: ${algosdk.bytesToBase64(globalValue)}`
Expand All @@ -163,7 +163,7 @@ async function main() {
`Raw local state - ${localState.map((kv) => algosdk.encodeJSON(kv))}`
);

const localKey = algosdk.base64ToBytes(localState[0].key);
const localKey = localState[0].key;
// get uint value directly
const localValue = localState[0].value.uint;

Expand Down
2 changes: 1 addition & 1 deletion examples/atc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function main() {

// example: ATC_BOX_REF
const boxATC = new algosdk.AtomicTransactionComposer();
const boxKey = new TextEncoder().encode('key');
const boxKey = algosdk.coerceToBytes('key');
boxATC.addMethodCall({
appID: appIndex,
method: boxAccessorMethod,
Expand Down
9 changes: 4 additions & 5 deletions examples/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function main() {
sender: sender.addr,
receiver: sender.addr,
amount: 1e6,
note: new TextEncoder().encode('Hello World!'),
note: algosdk.coerceToBytes('Hello World!'),
suggestedParams,
});

Expand All @@ -81,13 +81,12 @@ async function main() {
// example: INDEXER_PREFIX_SEARCH
const txnsWithNotePrefix = await indexerClient
.searchForTransactions()
.notePrefix(new TextEncoder().encode('Hello'))
.notePrefix(algosdk.coerceToBytes('Hello'))
.do();
console.log(
`Transactions with note prefix "Hello" ${algosdk.stringifyJSON(
`Transactions with note prefix "Hello" ${algosdk.encodeJSON(
txnsWithNotePrefix,
undefined,
2
{ space: 2 }
)}`
);
// example: INDEXER_PREFIX_SEARCH
Expand Down
6 changes: 2 additions & 4 deletions examples/lsig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function main() {

// example: LSIG_COMPILE
const smartSigSource = '#pragma version 8\nint 1\nreturn'; // approve everything
const result = await client
.compile(new TextEncoder().encode(smartSigSource))
.do();
const result = await client.compile(smartSigSource).do();

// Hash is equivalent to the contract address
console.log('Hash: ', result.hash);
Expand All @@ -28,7 +26,7 @@ async function main() {
// example: LSIG_INIT

// example: LSIG_PASS_ARGS
const args = [new TextEncoder().encode('This is an argument!')];
const args = [algosdk.coerceToBytes('This is an argument!')];
smartSig = new algosdk.LogicSig(algosdk.base64ToBytes(b64program), args);
// example: LSIG_PASS_ARGS

Expand Down
2 changes: 1 addition & 1 deletion examples/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function main() {
suggestedParams,
receiver: acct2.addr,
amount: 10000,
note: new TextEncoder().encode('hello world'),
note: algosdk.coerceToBytes('hello world'),
});
// example: TRANSACTION_PAYMENT_CREATE

Expand Down
4 changes: 1 addition & 3 deletions examples/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export async function compileProgram(
client: algosdk.Algodv2,
programSource: string
) {
const compileResponse = await client
.compile(new TextEncoder().encode(programSource))
.do();
const compileResponse = await client.compile(programSource).do();
const compiledBytes = algosdk.base64ToBytes(compileResponse.result);
return compiledBytes;
}
Expand Down
Loading