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

Use uint8array #308

Merged
merged 29 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dd800eb
cherry pick from arraybuffer branch
ailisp Nov 22, 2022
a78156d
reset builder
ailisp Nov 22, 2022
5187700
update builder.c, fix git diff
ailisp Nov 22, 2022
a947408
nit
ailisp Nov 22, 2022
ac487d1
merge develop
ailisp Nov 23, 2022
78ed2a6
resolve conflict
ailisp Nov 23, 2022
c1336a5
strictly different from uint8array and string, fix near-bindgen and u…
ailisp Nov 23, 2022
48a1023
Merge branch 'develop' into use-uint8array
ailisp Nov 29, 2022
c49802a
make collections use uint8array instead of bytes
ailisp Nov 29, 2022
b933287
commit build
ailisp Nov 30, 2022
e927de7
fix build and some tests
ailisp Nov 30, 2022
c09a8db
add text encoding decoding in c side, add TextEncoder and TextDecoder…
ailisp Dec 1, 2022
4adcb8f
refactor utf8 and latin1 api
ailisp Dec 2, 2022
46304fc
fix near bindgen and collections utf 8 char issue
ailisp Dec 2, 2022
18f3b61
fix bytes tests
ailisp Dec 5, 2022
eec8cb4
fix public key tests
ailisp Dec 5, 2022
8197aa6
merge develop
ailisp Dec 5, 2022
2826581
add all test cases of string<>uint8array conversion
ailisp Dec 6, 2022
f6b837c
lint format
ailisp Dec 6, 2022
9263d61
fix clean-state cross contract call loop, ft and programmatic update …
ailisp Dec 7, 2022
65d97ed
Merge branch 'develop' into use-uint8array
ailisp Dec 7, 2022
4e85aba
fixing my-nft.ts build
ailisp Dec 7, 2022
493ce71
fix all examples
ailisp Dec 8, 2022
5d05999
merge develop and resolve conflict
ailisp Dec 8, 2022
0d734ac
remove unused file
ailisp Dec 8, 2022
2d4b3a5
fix test
ailisp Dec 8, 2022
56a7a99
address Serhii comments
ailisp Dec 12, 2022
e8f9c08
keep string APIs mostly backward compatible, make raw apis, fix tests
ailisp Dec 13, 2022
ea494c6
fix tests
ailisp Dec 13, 2022
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
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