You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes step to do a new pre-release or formal release.
4
+
5
+
## Release Requirement
6
+
- A formal release must be directly bump from a tested, DevRel Team approved pre-release, with no commits other than bump the version.
7
+
- Pre-release can come with arbitrary commits to fix packaging and update documentations. Several pre-release can be released before a formal release to fix issues and address feedbacks.
8
+
9
+
## Steps for pre-release
10
+
1. Create a new branch for the release.
11
+
2. Bump version in packages/near-sdk-js/package.json and packages/near-contract-standards/package.json to the version about to release. It should be `x.y.z-0`, and next pre-release `x.y.z-1`, etc.
12
+
3. Run `pnpm publish` in packages/near-sdk-js and in packages/near-contract-standards.
13
+
4. Copy examples folder in this repo to another place, drop `node_modules`, change its package.json from:
14
+
```
15
+
"near-contract-standards": "workspace:*",
16
+
"near-sdk-js": "workspace:*",
17
+
```
18
+
to the version you just released, e.g. `x.y.z-1`.
19
+
5. Build and run example tests to ensure the packaging is correct.
20
+
6. If it works, go to https://github.com/near/near-sdk-js/releases/new, create a tag for the new release from the branch you created in step 1, and write the release highlights.
21
+
7. Ask the DevRel team to test the pre-release.
22
+
23
+
## Steps for formal release
24
+
1. Create a new release branch from the candidate pre-release branch
25
+
2. Bump version in packages/near-sdk-js/package.json and packages/near-contract-standards/package.json to the version about to release. It should be `x.y.z`.
26
+
3. Run `pnpm publish` in packages/near-sdk-js and in packages/near-contract-standards.
27
+
4. Go to https://github.com/near/near-sdk-js/releases/new, create a tag for the new release branch from the branch you created in step 1, and copy the highlights from latest pre-release candidate.
Copy file name to clipboardExpand all lines: packages/near-sdk-js/README.md
+70-45
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,12 @@ When call host function with inappropriate type, means incorrect number of argum
60
60
- if argument is different than the required type, it'll be coerced to required type
61
61
- if argument is different than the required type but cannot be coerced, will throw runtime type error, also with message and stacktrace
62
62
63
+
## Migrating from near-sdk-js 0.6.0
64
+
65
+
If you have a near-sdk-js 0.6.0 contract, you need to drop the `babel.config.json` because it is now inlined in near-sdk-js CLI.
66
+
67
+
Also `Bytes` type in 0.6.0 is replaced with `string` and `Uint8Array`. Because `Bytes` was an alias to `string`, this doesn't affect all collection APIs and most low level APIs. Some low level APIs below now also comes with a raw version, which ends with `Raw` and takes `Uint8Array` instead of `string`, for example, `storageRead` vs `storageReadRaw`. Some low level APIs have more sense to use `Uint8Array` instead of `string`, such as `sha256` and arguments for a function call type of promise, these are **BREAKING** changes. Please refer to next section for details: look for functions with `Uint8Array` argument and return types.
68
+
63
69
## NEAR-SDK-JS API Reference
64
70
65
71
All NEAR blockchain provided functionality (host functions) are defined in `src/api.ts` and exported as `near`. You can use them by:
@@ -83,18 +89,17 @@ pnpm build
83
89
NEAR-SDK-JS is written in TypeScript, so every API function has a type specified by signature that looks familiar to JavaScript/TypeScript Developers. Two types in the signature need a special attention:
84
90
85
91
- Most of the API take `bigint` instead of Number as type. This because JavaScript Number cannot hold 64 bit and 128 bit integer without losing precision.
86
-
-`Bytes` in both arguments and return represent a byte buffer, internally it's a JavaScript String Object. Any binary data `0x00-0xff` is stored as the char '\x00-\xff'. This is because QuickJS doesn't have Uint8Array in C API.
87
-
- To ensure correctness, every `Bytes` argument need to be pass in with the `bytes()` function to runtime type check it's indeed a `Bytes`.
88
-
- If `Bytes` is too long that `bytes()` can cause gas limit problem, such as in factory contract, represents the content of contract to be deployed. In this case you can precheck and guarantee the correctness of the content and use without `bytes()`.
92
+
- For those API that takes or returns raw bytes, it is a JavaScript `Uint8Array`. You can use standard `Uint8Array` methods on it or decode it to string with `decode` or `str`. The differece between `decode` and `str` is: `decode` decode the array as UTF-8 sequence. `str` simply converts each Uint8 to one char with that char code.
function promiseBatchActionDeleteKey(promise_index: PromiseIndex, public_key: Uint8Array);
166
+
function promiseBatchActionDeleteAccount(promise_index: PromiseIndex, beneficiary_id: string);
161
167
```
162
168
163
169
### Promise API results
164
170
165
171
```
166
172
function promiseResultsCount(): bigint;
167
-
function promiseResult(result_idx: bigint, register_id: bigint): bigint;
168
-
function promiseReturn(promise_idx: bigint);
173
+
function promiseResultRaw(result_idx: PromiseIndex): Uint8Array;
174
+
function promiseResult(result_idx: PromiseIndex): string;
175
+
function promiseReturn(promise_idx: PromiseIndex);
169
176
```
170
177
171
178
### Storage API
172
179
173
180
```
174
-
function storageWrite(key: Bytes, value: Bytes, register_id: bigint): bigint;
175
-
function storageRead(key: Bytes, register_id: bigint): bigint;
176
-
function storageRemove(key: Bytes, register_id: bigint): bigint;
177
-
function storageHasKey(key: Bytes): bigint;
181
+
function storageWriteRaw(key: Uint8Array, value: Uint8Array): boolean;
182
+
function storageReadRaw(key: Uint8Array): Uint8Array | null;
183
+
function storageRemoveRaw(key: Uint8Array): boolean;
184
+
function storageHasKeyRaw(key: Uint8Array): boolean;
185
+
function storageWrite(key: string, value: string): boolean;
186
+
function storageRead(key: string): bigint;
187
+
function storageRemove(key: string): bigint;
188
+
function storageHasKey(key: string): bigint;
178
189
```
179
190
180
191
### Validator API
@@ -187,9 +198,9 @@ function validatorTotalStake(): bigint;
187
198
### Alt BN128
188
199
189
200
```
190
-
function altBn128G1Multiexp(value: Bytes, register_id: bigint);
191
-
function altBn128G1Sum(value: Bytes, register_id: bigint);
192
-
function altBn128PairingCheck(value: Bytes): bigint;
201
+
function altBn128G1Multiexp(value: Uint8Array): Uint8Array;
202
+
function altBn128G1Sum(value: Uint8Array): Uint8Array;
203
+
function altBn128PairingCheck(value: Uint8Array): boolean;
193
204
```
194
205
195
206
### NearBindgen and other decorators
@@ -225,7 +236,7 @@ In order to initialize the contract, you need to add functions flagged with `@in
225
236
226
237
### Collections
227
238
228
-
A few useful on-chain persistent collections are provided. All keys, values and elements are of type `Bytes`.
239
+
A few useful on-chain persistent collections are provided. All keys, values and elements are of type `string`.
229
240
230
241
#### Vector
231
242
@@ -532,21 +543,35 @@ return promise;
532
543
533
544
### Types
534
545
535
-
NEAR-SDK-JS also includes type defintions that are equivalent to that in Rust SDK / nearcore. You can browse them in near-sdk-js/src/types. Most of them are just type alias to Bytes and bigint.
546
+
NEAR-SDK-JS also includes type defintions that are equivalent to that in Rust SDK / nearcore. You can browse them in near-sdk-js/src/types. Most of them are just type alias to string and bigint.
536
547
537
548
#### Public Key
538
549
539
550
Public Key is representing a NEAR account's public key in a JavaScript class. You can either initiate a Public Key from binary data, or from a human readable string.
540
551
541
-
The binary data is in the same format as nearcore, but encoded in bytes. That's one byte to represent the curve type of the public key, either ed25519 (`\x00`), or secp256k1 ('\x01'), follows by the curve-specific public key data in bytes. Examples:
552
+
The binary data is in the same format as nearcorein `Uint8Array`. That's one byte to represent the curve type of the public key, either ed25519 (`0x0`), or secp256k1 (`0x1`), follows by the curve-specific public key data in bytes. Examples:
0 commit comments