Skip to content

Commit

Permalink
Merge pull request #308 from near/use-uint8array
Browse files Browse the repository at this point in the history
Use uint8array
  • Loading branch information
ailisp authored Dec 13, 2022
2 parents 2a51b6c + ea494c6 commit d1ca261
Show file tree
Hide file tree
Showing 64 changed files with 1,766 additions and 743 deletions.
4 changes: 2 additions & 2 deletions examples/src/cross-contract-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export class OnCall {
near.promiseBatchActionFunctionCall(
promise,
"get_status",
bytes(JSON.stringify({ account_id: accountId })),
JSON.stringify({ account_id: accountId }),
0,
30000000000000
);
near.promiseThen(
promise,
near.currentAccountId(),
"_set_person_on_call_private",
bytes(JSON.stringify({ accountId: accountId })),
JSON.stringify({ accountId: accountId }),
0,
30000000000000
);
Expand Down
6 changes: 2 additions & 4 deletions examples/src/non-fungible-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,20 @@ export class NftContract {
near.promiseBatchActionFunctionCall(
promise,
"nftOnTransfer",
bytes(
JSON.stringify({
senderId: sender_id,
previousOwnerId: old_owner_id,
tokenId: token_id,
msg: msg,
})
),
}),
0,
30000000000000
);
near.promiseThen(
promise,
near.currentAccountId(),
"_nftResolveTransfer",
bytes(JSON.stringify({ sender_id, receiver_id, token_id })),
JSON.stringify({ sender_id, receiver_id, token_id }),
0,
30000000000000
);
Expand Down
2 changes: 1 addition & 1 deletion examples/src/programmatic-update-after.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function updateContract() {
);

const promiseId = near.promiseBatchCreate(near.currentAccountId());
near.promiseBatchActionDeployContract(promiseId, near.input());
near.promiseBatchActionDeployContract(promiseId, near.inputRaw());

return near.promiseReturn(promiseId);
}
2 changes: 1 addition & 1 deletion examples/src/programmatic-update-before.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function updateContract() {
);

const promiseId = near.promiseBatchCreate(near.currentAccountId());
near.promiseBatchActionDeployContract(promiseId, near.input());
near.promiseBatchActionDeployContract(promiseId, near.inputRaw());

return near.promiseReturn(promiseId);
}
10 changes: 5 additions & 5 deletions examples/src/standard-nft/my-nft.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NonFungibleToken } from "near-contract-standards/lib";
import {
assert,
Bytes,
bytes,
call,
initialize,
near,
Expand Down Expand Up @@ -32,25 +32,25 @@ import { NonFungibleTokenEnumeration } from "near-contract-standards/lib/non_fun
class StorageKey {}

class StorageKeyNonFungibleToken extends StorageKey implements IntoStorageKey {
into_storage_key(): Bytes {
into_storage_key(): string {
return "NFT_";
}
}

class StorageKeyTokenMetadata extends StorageKey implements IntoStorageKey {
into_storage_key(): Bytes {
into_storage_key(): string {
return "TOKEN_METADATA_";
}
}

class StorageKeyTokenEnumeration extends StorageKey implements IntoStorageKey {
into_storage_key(): Bytes {
into_storage_key(): string {
return "TOKEN_ENUMERATION_";
}
}

class StorageKeyApproval extends StorageKey implements IntoStorageKey {
into_storage_key(): Bytes {
into_storage_key(): string {
return "APPROVAL1_";
}
}
Expand Down
5 changes: 2 additions & 3 deletions examples/src/standard-nft/test-approval-receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
PromiseOrValue,
assert,
call,
bytes,
serialize,
} from "near-sdk-js";
import { AccountId } from "near-sdk-js";
Expand Down Expand Up @@ -56,9 +55,9 @@ export class ApprovalReceiver
default: {
const prepaid_gas = near.prepaidGas();
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
return NearPromise.new(account_id).functionCallRaw(
"ok_go",
bytes(serialize({ msg })),
serialize({ msg }),
0n,
prepaid_gas - GAS_FOR_NFT_ON_APPROVE
);
Expand Down
9 changes: 4 additions & 5 deletions examples/src/standard-nft/test-token-receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
NearBindgen,
NearPromise,
PromiseOrValue,
bytes,
serialize,
} from "near-sdk-js";
import { AccountId } from "near-sdk-js";
Expand Down Expand Up @@ -64,9 +63,9 @@ export class TokenReceiver
case "return-it-later": {
const prepaid_gas = near.prepaidGas();
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
return NearPromise.new(account_id).functionCallRaw(
"ok_go",
bytes(serialize({ return_it: true })),
serialize({ return_it: true }),
0n,
prepaid_gas - GAS_FOR_NFT_ON_TRANSFER
);
Expand All @@ -76,9 +75,9 @@ export class TokenReceiver
case "keep-it-later": {
const prepaid_gas = near.prepaidGas();
const account_id = near.currentAccountId();
return NearPromise.new(account_id).functionCall(
return NearPromise.new(account_id).functionCallRaw(
"ok_go",
bytes(serialize({ return_it: false })),
serialize({ return_it: false }),
0n,
prepaid_gas - GAS_FOR_NFT_ON_TRANSFER
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions packages/near-contract-standards/lib/non_fungible_token/impl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d1ca261

Please sign in to comment.