@solana/web3.js 0.98.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -55
- package/lib/index.browser.esm.js +48 -24
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +101 -56
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +88 -64
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +42 -25
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +27 -45
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +37 -0
- package/src/validator-info.ts +5 -4
- package/bin/bpf-sdk-install.sh +0 -38
- package/bin/localnet.sh +0 -161
- package/bpf-sdk/LICENSE +0 -13
- package/bpf-sdk/c/README.md +0 -44
- package/bpf-sdk/c/bpf.ld +0 -20
- package/bpf-sdk/c/bpf.mk +0 -249
- package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
- package/bpf-sdk/c/inc/solana_sdk.h +0 -669
- package/bpf-sdk/c/inc/stdio.h +0 -4
- package/bpf-sdk/c/inc/stdlib.h +0 -2
- package/bpf-sdk/c/inc/string.h +0 -7
- package/bpf-sdk/c/inc/sys/param.h +0 -1
- package/bpf-sdk/c/inc/wchar.h +0 -1
- package/bpf-sdk/env.sh +0 -39
- package/bpf-sdk/rust/bpf.ld +0 -20
- package/bpf-sdk/rust/build.sh +0 -21
- package/bpf-sdk/rust/clean.sh +0 -17
- package/bpf-sdk/rust/xargo-build.sh +0 -29
- package/bpf-sdk/scripts/dump.sh +0 -45
- package/bpf-sdk/scripts/install.sh +0 -178
- package/bpf-sdk/scripts/objcopy.sh +0 -6
- package/bpf-sdk/scripts/package.sh +0 -19
- package/bpf-sdk/scripts/strip.sh +0 -23
- package/bpf-sdk/version.txt +0 -2
- package/doc/assets/css/main.css +0 -2660
- package/doc/assets/images/icons.png +0 -0
- package/doc/assets/images/icons@2x.png +0 -0
- package/doc/assets/images/widgets.png +0 -0
- package/doc/assets/images/widgets@2x.png +0 -0
- package/doc/assets/js/main.js +0 -248
- package/doc/assets/js/search.js +0 -1
- package/doc/classes/account.html +0 -244
- package/doc/classes/authorized.html +0 -234
- package/doc/classes/bpfloader.html +0 -267
- package/doc/classes/connection.html +0 -2354
- package/doc/classes/loader.html +0 -275
- package/doc/classes/lockup.html +0 -250
- package/doc/classes/message.html +0 -326
- package/doc/classes/nonceaccount.html +0 -233
- package/doc/classes/publickey.html +0 -411
- package/doc/classes/secp256k1program.html +0 -308
- package/doc/classes/stakeinstruction.html +0 -403
- package/doc/classes/stakeprogram.html +0 -503
- package/doc/classes/systeminstruction.html +0 -563
- package/doc/classes/systemprogram.html +0 -503
- package/doc/classes/transaction.html +0 -688
- package/doc/classes/transactioninstruction.html +0 -240
- package/doc/classes/validatorinfo.html +0 -279
- package/doc/classes/voteaccount.html +0 -331
- package/doc/index.html +0 -640
- package/doc/interfaces/feecalculator.html +0 -166
- package/doc/modules.html +0 -4682
- package/examples/README.md +0 -10
- package/examples/account.html +0 -24
- package/examples/account.js +0 -10
- package/examples/bpf-c-noop/.gitignore +0 -1
- package/examples/bpf-c-noop/makefile +0 -1
- package/examples/bpf-c-noop/src/noop/noop.c +0 -19
- package/examples/bpf-rust-noop/.gitignore +0 -3
- package/examples/bpf-rust-noop/Cargo.toml +0 -23
- package/examples/bpf-rust-noop/Xargo.toml +0 -2
- package/examples/bpf-rust-noop/src/lib.rs +0 -70
- package/examples/get-balance.html +0 -37
- package/examples/get-balance.js +0 -18
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/util/to-buffer.ts","../../src/publickey.ts","../../src/account.ts","../../src/blockhash.ts","../../src/bpf-loader-deprecated.ts","../../src/layout.ts","../../src/util/shortvec-encoding.ts","../../src/message.ts","../../src/transaction.ts","../../src/sysvar.ts","../../src/agent-manager.ts","../../src/fee-calculator.ts","../../src/nonce-account.ts","../../src/timing.ts","../../src/util/sleep.ts","../../src/util/promise-timeout.ts","../../src/connection.ts","../../src/util/send-and-confirm-transaction.ts","../../src/instruction.ts","../../src/system-program.ts","../../src/loader.ts","../../src/bpf-loader.ts","../../src/stake-program.ts","../../src/secp256k1-program.ts","../../src/validator-info.ts","../../src/vote-account.ts","../../src/util/send-and-confirm-raw-transaction.ts","../../src/util/cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/util/to-buffer.ts","../../src/publickey.ts","../../src/account.ts","../../src/blockhash.ts","../../src/bpf-loader-deprecated.ts","../../src/layout.ts","../../src/util/shortvec-encoding.ts","../../src/util/guarded-array-utils.ts","../../src/message.ts","../../src/transaction.ts","../../src/sysvar.ts","../../src/agent-manager.ts","../../src/fee-calculator.ts","../../src/nonce-account.ts","../../src/timing.ts","../../src/util/sleep.ts","../../src/util/promise-timeout.ts","../../src/connection.ts","../../src/util/send-and-confirm-transaction.ts","../../src/instruction.ts","../../src/system-program.ts","../../src/loader.ts","../../src/bpf-loader.ts","../../src/stake-program.ts","../../src/secp256k1-program.ts","../../src/validator-info.ts","../../src/vote-account.ts","../../src/util/send-and-confirm-raw-transaction.ts","../../src/util/cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJjye;;GAEG;AACH,QAAO,MAAM,gBAAgB,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -31,53 +31,11 @@
|
|
|
31
31
|
"not IE 11",
|
|
32
32
|
"maintained node versions"
|
|
33
33
|
],
|
|
34
|
-
"bin": {
|
|
35
|
-
"solana-bpf-sdk-install": "bin/bpf-sdk-install.sh",
|
|
36
|
-
"solana-localnet": "bin/localnet.sh"
|
|
37
|
-
},
|
|
38
|
-
"testnetDefaultChannel": "edge",
|
|
39
34
|
"files": [
|
|
40
|
-
"/bin",
|
|
41
|
-
"/doc",
|
|
42
|
-
"/examples",
|
|
43
|
-
"/bpf-sdk",
|
|
44
35
|
"/lib",
|
|
45
36
|
"/module.flow.js",
|
|
46
37
|
"/src"
|
|
47
38
|
],
|
|
48
|
-
"scripts": {
|
|
49
|
-
"bpf-sdk:install": "npm run clean:fixtures; bin/bpf-sdk-install.sh .",
|
|
50
|
-
"bpf-sdk:remove-symlinks": "find bpf-sdk -type l -print -exec cp {} {}.tmp \\; -exec mv {}.tmp {} \\;",
|
|
51
|
-
"build": "cross-env NODE_ENV=production rollup -c; npx flowgen lib/types/index.d.ts -o module.flow.js",
|
|
52
|
-
"build:browser-test": "rollup -c test/rollup.config.js",
|
|
53
|
-
"build:fixtures": "set -ex; ./test/fixtures/noop-c/build.sh; ./test/fixtures/noop-rust/build.sh",
|
|
54
|
-
"clean:fixtures": "make -C examples/bpf-c-noop clean ",
|
|
55
|
-
"clean": "rimraf ./coverage ./lib",
|
|
56
|
-
"codecov": "set -ex; npm run test:cover; cat ./coverage/lcov.info | codecov",
|
|
57
|
-
"dev": "cross-env NODE_ENV=development rollup -c",
|
|
58
|
-
"doc": "set -ex; typedoc",
|
|
59
|
-
"doc:watch": "watch 'npm run doc' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
|
60
|
-
"examples": "set -ex; for example in examples/*.js; do node $example; done",
|
|
61
|
-
"lint": "set -ex; npm run pretty; eslint . --ext .js,.ts",
|
|
62
|
-
"lint:fix": "npm run pretty:fix && eslint . --fix",
|
|
63
|
-
"lint:watch": "watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
|
64
|
-
"localnet:down": "bin/localnet.sh down",
|
|
65
|
-
"localnet:logs": "bin/localnet.sh logs -f",
|
|
66
|
-
"localnet:up": "bin/localnet.sh up",
|
|
67
|
-
"localnet:update": "bin/localnet.sh update",
|
|
68
|
-
"ok": "run-s lint test doc",
|
|
69
|
-
"prepare": "run-s clean bpf-sdk:install bpf-sdk:remove-symlinks build",
|
|
70
|
-
"pretty": "prettier --check '{,{examples,src,test}/**/}*.{j,t}s'",
|
|
71
|
-
"pretty:fix": "prettier --write '{,{examples,src,test}/**/}*.{j,t}s'",
|
|
72
|
-
"re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
73
|
-
"test": "npm run build:fixtures && mocha -r ts-node/register './test/**/*.test.ts'",
|
|
74
|
-
"test:cover": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' nyc --reporter=lcov mocha -r ts-node/register './test/**/*.test.ts'",
|
|
75
|
-
"test:browser": "TEST_LIVE=1 npm run build:fixtures && npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000",
|
|
76
|
-
"test:browser-with-server": "start-server-and-test 'http-server -p 8080' 8080 test:browser",
|
|
77
|
-
"test:browser-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:browser-with-server",
|
|
78
|
-
"test:live": "TEST_LIVE=1 npm run test",
|
|
79
|
-
"test:live-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:live"
|
|
80
|
-
},
|
|
81
39
|
"dependencies": {
|
|
82
40
|
"@babel/runtime": "^7.12.5",
|
|
83
41
|
"bn.js": "^5.0.0",
|
|
@@ -141,7 +99,7 @@
|
|
|
141
99
|
"nyc": "^15.1.0",
|
|
142
100
|
"prettier": "^2.0.0",
|
|
143
101
|
"rimraf": "3.0.2",
|
|
144
|
-
"rollup": "2.
|
|
102
|
+
"rollup": "2.42.0",
|
|
145
103
|
"rollup-plugin-flat-dts": "^1.0.3",
|
|
146
104
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
147
105
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -154,5 +112,29 @@
|
|
|
154
112
|
"typedoc": "^0.20.31",
|
|
155
113
|
"typescript": "^4.1.5",
|
|
156
114
|
"watch": "^1.0.2"
|
|
115
|
+
},
|
|
116
|
+
"scripts": {
|
|
117
|
+
"build": "cross-env NODE_ENV=production rollup -c; npx flowgen lib/types/index.d.ts -o module.flow.js",
|
|
118
|
+
"build:browser-test": "rollup -c test/rollup.config.js",
|
|
119
|
+
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
|
120
|
+
"clean": "rimraf ./coverage ./lib",
|
|
121
|
+
"codecov": "set -ex; npm run test:cover; cat ./coverage/lcov.info | codecov",
|
|
122
|
+
"dev": "cross-env NODE_ENV=development rollup -c",
|
|
123
|
+
"doc": "set -ex; typedoc",
|
|
124
|
+
"doc:watch": "watch 'npm run doc' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
|
125
|
+
"lint": "set -ex; npm run pretty; eslint . --ext .js,.ts",
|
|
126
|
+
"lint:fix": "npm run pretty:fix && eslint . --fix",
|
|
127
|
+
"lint:watch": "watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
|
128
|
+
"ok": "run-s lint test doc",
|
|
129
|
+
"pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
130
|
+
"pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
131
|
+
"re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
132
|
+
"test": "mocha -r ts-node/register './test/**/*.test.ts'",
|
|
133
|
+
"test:cover": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' nyc --reporter=lcov mocha -r ts-node/register './test/**/*.test.ts'",
|
|
134
|
+
"test:browser": "TEST_LIVE=1 npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000",
|
|
135
|
+
"test:browser-with-server": "start-server-and-test 'http-server -p 8080' 8080 test:browser",
|
|
136
|
+
"test:browser-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:browser-with-server",
|
|
137
|
+
"test:live": "TEST_LIVE=1 npm run test",
|
|
138
|
+
"test:live-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:live"
|
|
157
139
|
}
|
|
158
|
-
}
|
|
140
|
+
}
|
package/src/message.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {Blockhash} from './blockhash';
|
|
|
7
7
|
import * as Layout from './layout';
|
|
8
8
|
import {PACKET_DATA_SIZE} from './transaction';
|
|
9
9
|
import * as shortvec from './util/shortvec-encoding';
|
|
10
|
+
import {guardedShift, guardedSplice} from './util/guarded-array-utils';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* The message header, identifying signed and read-only account
|
|
@@ -177,32 +178,28 @@ export class Message {
|
|
|
177
178
|
// Slice up wire data
|
|
178
179
|
let byteArray = [...buffer];
|
|
179
180
|
|
|
180
|
-
const numRequiredSignatures = byteArray
|
|
181
|
-
const numReadonlySignedAccounts = byteArray
|
|
182
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
181
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
182
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
183
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
183
184
|
|
|
184
185
|
const accountCount = shortvec.decodeLength(byteArray);
|
|
185
186
|
let accountKeys = [];
|
|
186
187
|
for (let i = 0; i < accountCount; i++) {
|
|
187
|
-
const account = byteArray
|
|
188
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
188
|
+
const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
189
189
|
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
const recentBlockhash = byteArray
|
|
193
|
-
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
192
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
|
|
194
193
|
|
|
195
194
|
const instructionCount = shortvec.decodeLength(byteArray);
|
|
196
195
|
let instructions: CompiledInstruction[] = [];
|
|
197
196
|
for (let i = 0; i < instructionCount; i++) {
|
|
198
|
-
const programIdIndex = byteArray
|
|
197
|
+
const programIdIndex = guardedShift(byteArray);
|
|
199
198
|
const accountCount = shortvec.decodeLength(byteArray);
|
|
200
|
-
const accounts = byteArray
|
|
201
|
-
byteArray = byteArray.slice(accountCount);
|
|
199
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
202
200
|
const dataLength = shortvec.decodeLength(byteArray);
|
|
203
|
-
const dataSlice = byteArray
|
|
201
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
204
202
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
205
|
-
byteArray = byteArray.slice(dataLength);
|
|
206
203
|
instructions.push({
|
|
207
204
|
programIdIndex,
|
|
208
205
|
accounts,
|
package/src/transaction.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {Account} from './account';
|
|
|
10
10
|
import * as shortvec from './util/shortvec-encoding';
|
|
11
11
|
import type {Blockhash} from './blockhash';
|
|
12
12
|
import {toBuffer} from './util/to-buffer';
|
|
13
|
+
import {guardedSplice} from './util/guarded-array-utils';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @typedef {string} TransactionSignature
|
|
@@ -667,8 +668,7 @@ export class Transaction {
|
|
|
667
668
|
const signatureCount = shortvec.decodeLength(byteArray);
|
|
668
669
|
let signatures = [];
|
|
669
670
|
for (let i = 0; i < signatureCount; i++) {
|
|
670
|
-
const signature = byteArray
|
|
671
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH);
|
|
671
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
|
|
672
672
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
673
673
|
}
|
|
674
674
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
5
|
+
*/
|
|
6
|
+
export function guardedShift<T>(byteArray: T[]): T {
|
|
7
|
+
if (byteArray.length === 0) {
|
|
8
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
9
|
+
}
|
|
10
|
+
return byteArray.shift() as T;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
15
|
+
* the array.
|
|
16
|
+
*/
|
|
17
|
+
export function guardedSplice<T>(
|
|
18
|
+
byteArray: T[],
|
|
19
|
+
...args:
|
|
20
|
+
| [start: number, deleteCount?: number]
|
|
21
|
+
| [start: number, deleteCount: number, ...items: T[]]
|
|
22
|
+
): T[] {
|
|
23
|
+
var _args$;
|
|
24
|
+
const [start] = args;
|
|
25
|
+
if (
|
|
26
|
+
args.length === 2 // Implies that `deleteCount` was supplied
|
|
27
|
+
? start +
|
|
28
|
+
((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) >
|
|
29
|
+
byteArray.length
|
|
30
|
+
: start >= byteArray.length
|
|
31
|
+
) {
|
|
32
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
return byteArray.splice(
|
|
35
|
+
...(args as Parameters<typeof Array.prototype.splice>),
|
|
36
|
+
);
|
|
37
|
+
}
|
package/src/validator-info.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import * as Layout from './layout';
|
|
10
10
|
import * as shortvec from './util/shortvec-encoding';
|
|
11
11
|
import {PublicKey} from './publickey';
|
|
12
|
+
import {guardedShift, guardedSplice} from './util/guarded-array-utils';
|
|
12
13
|
|
|
13
14
|
export const VALIDATOR_INFO_KEY = new PublicKey(
|
|
14
15
|
'Va1idator1nfo111111111111111111111111111111',
|
|
@@ -87,10 +88,10 @@ export class ValidatorInfo {
|
|
|
87
88
|
|
|
88
89
|
const configKeys: Array<ConfigKey> = [];
|
|
89
90
|
for (let i = 0; i < 2; i++) {
|
|
90
|
-
const publicKey = new PublicKey(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const publicKey = new PublicKey(
|
|
92
|
+
guardedSplice(byteArray, 0, PUBKEY_LENGTH),
|
|
93
|
+
);
|
|
94
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
94
95
|
configKeys.push({publicKey, isSigner});
|
|
95
96
|
}
|
|
96
97
|
|
package/bin/bpf-sdk-install.sh
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
installDir=$1
|
|
5
|
-
if [[ -z $installDir ]]; then
|
|
6
|
-
installDir="$(cd "$(dirname "$0")"/..; pwd)"
|
|
7
|
-
fi
|
|
8
|
-
|
|
9
|
-
channel=$(
|
|
10
|
-
cd "$(dirname "$0")";
|
|
11
|
-
node -p '
|
|
12
|
-
let p = [
|
|
13
|
-
"../../package.json",
|
|
14
|
-
"../lib/node_modules/@solana/web3.js/package.json",
|
|
15
|
-
"../@solana/web3.js/package.json",
|
|
16
|
-
"../package.json"
|
|
17
|
-
].find(require("fs").existsSync);
|
|
18
|
-
if (!p) throw new Error("Unable to locate package.json");
|
|
19
|
-
require(p)["testnetDefaultChannel"]
|
|
20
|
-
'
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
if [[ -n $2 ]]; then
|
|
24
|
-
channel=$2
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
echo "Installing $channel BPF SDK into $installDir"
|
|
28
|
-
|
|
29
|
-
set -x
|
|
30
|
-
cd "$installDir/"
|
|
31
|
-
curl -L --retry 5 --retry-delay 2 -o bpf-sdk.tar.bz2 \
|
|
32
|
-
https://solana-sdk.s3.amazonaws.com/"$channel"/bpf-sdk.tar.bz2
|
|
33
|
-
rm -rf bpf-sdk
|
|
34
|
-
mkdir -p bpf-sdk
|
|
35
|
-
tar jxf bpf-sdk.tar.bz2
|
|
36
|
-
rm -f bpf-sdk.tar.bz2
|
|
37
|
-
|
|
38
|
-
cat bpf-sdk/version.txt
|
package/bin/localnet.sh
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
channel=$(
|
|
5
|
-
cd "$(dirname "$0")";
|
|
6
|
-
node -p '
|
|
7
|
-
let p = [
|
|
8
|
-
"../../package.json",
|
|
9
|
-
"../lib/node_modules/@solana/web3.js/package.json",
|
|
10
|
-
"../@solana/web3.js/package.json",
|
|
11
|
-
"../package.json"
|
|
12
|
-
].find(require("fs").existsSync);
|
|
13
|
-
if (!p) throw new Error("Unable to locate package.json");
|
|
14
|
-
require(p)["testnetDefaultChannel"]
|
|
15
|
-
'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
usage() {
|
|
19
|
-
exitcode=0
|
|
20
|
-
if [[ -n "$1" ]]; then
|
|
21
|
-
exitcode=1
|
|
22
|
-
echo "Error: $*"
|
|
23
|
-
fi
|
|
24
|
-
cat <<EOF
|
|
25
|
-
usage: $0 [update|up|down|logs] [command-specific options]
|
|
26
|
-
|
|
27
|
-
Operate a local testnet
|
|
28
|
-
|
|
29
|
-
update - Update the image from dockerhub.com
|
|
30
|
-
up - Start the cluster
|
|
31
|
-
down - Stop the cluster
|
|
32
|
-
logs - Display cluster logging
|
|
33
|
-
|
|
34
|
-
logs-specific options:
|
|
35
|
-
-f - Follow log output
|
|
36
|
-
|
|
37
|
-
update-specific options:
|
|
38
|
-
<tag> - Optional Docker image tag to use
|
|
39
|
-
|
|
40
|
-
up-specific options:
|
|
41
|
-
<tag> - Optional Docker image tag to use
|
|
42
|
-
-n - Optional Docker network to join
|
|
43
|
-
|
|
44
|
-
Default channel: $channel
|
|
45
|
-
|
|
46
|
-
down-specific options:
|
|
47
|
-
none
|
|
48
|
-
|
|
49
|
-
EOF
|
|
50
|
-
exit $exitcode
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
[[ -n $1 ]] || usage
|
|
54
|
-
cmd="$1"
|
|
55
|
-
shift
|
|
56
|
-
|
|
57
|
-
docker --version || usage "It appears that docker is not installed"
|
|
58
|
-
case $cmd in
|
|
59
|
-
update)
|
|
60
|
-
if [[ -n $1 ]]; then
|
|
61
|
-
channel="$1"
|
|
62
|
-
fi
|
|
63
|
-
(
|
|
64
|
-
set -x
|
|
65
|
-
docker pull solanalabs/solana:"$channel"
|
|
66
|
-
)
|
|
67
|
-
;;
|
|
68
|
-
up)
|
|
69
|
-
while [[ -n $1 ]]; do
|
|
70
|
-
if [[ $1 = -n ]]; then
|
|
71
|
-
[[ -n $2 ]] || usage "Invalid $1 argument"
|
|
72
|
-
network="$2"
|
|
73
|
-
shift 2
|
|
74
|
-
else
|
|
75
|
-
channel=$1
|
|
76
|
-
shift 1
|
|
77
|
-
fi
|
|
78
|
-
done
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
set -x
|
|
82
|
-
RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug}
|
|
83
|
-
ARGS=(
|
|
84
|
-
--detach
|
|
85
|
-
--name solana-localnet
|
|
86
|
-
--rm
|
|
87
|
-
--publish 8001:8001/tcp # entrypoint
|
|
88
|
-
--publish 8899:8899/tcp # rpc http
|
|
89
|
-
--publish 8900:8900/tcp # rpc pubsub
|
|
90
|
-
--publish 8901:8901/tcp # (future) bank service
|
|
91
|
-
--publish 8902:8902/tcp # bank service
|
|
92
|
-
--publish 9900:9900/tcp # faucet
|
|
93
|
-
--publish 8000:8000/udp # tvu
|
|
94
|
-
--publish 8001:8001/udp # gossip
|
|
95
|
-
--publish 8002:8002/udp # tvu_forwards
|
|
96
|
-
--publish 8003:8003/udp # tpu
|
|
97
|
-
--publish 8004:8004/udp # tpu_forwards
|
|
98
|
-
--publish 8005:8005/udp # retransmit
|
|
99
|
-
--publish 8006:8006/udp # repair
|
|
100
|
-
--publish 8007:8007/udp # serve_repair
|
|
101
|
-
--publish 8008:8008/udp # broadcast
|
|
102
|
-
--tty
|
|
103
|
-
--ulimit "nofile=700000"
|
|
104
|
-
--env "RUST_LOG=$RUST_LOG"
|
|
105
|
-
)
|
|
106
|
-
if [[ -n $network ]]; then
|
|
107
|
-
ARGS+=(--network "$network")
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
docker run "${ARGS[@]}" solanalabs/solana:"$channel"
|
|
111
|
-
|
|
112
|
-
for _ in 1 2 3 4 5; do
|
|
113
|
-
if curl \
|
|
114
|
-
-X POST \
|
|
115
|
-
-H "Content-Type: application/json" \
|
|
116
|
-
-d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' \
|
|
117
|
-
http://localhost:8899; then
|
|
118
|
-
break;
|
|
119
|
-
fi
|
|
120
|
-
sleep 1
|
|
121
|
-
done
|
|
122
|
-
)
|
|
123
|
-
;;
|
|
124
|
-
down)
|
|
125
|
-
(
|
|
126
|
-
set -x
|
|
127
|
-
if [[ $(docker ps --filter "name=^/solana-localnet$" -q) ]]; then
|
|
128
|
-
docker stop --time 0 solana-localnet
|
|
129
|
-
fi
|
|
130
|
-
)
|
|
131
|
-
;;
|
|
132
|
-
logs)
|
|
133
|
-
follow=false
|
|
134
|
-
if [[ -n $1 ]]; then
|
|
135
|
-
if [[ $1 = "-f" ]]; then
|
|
136
|
-
follow=true
|
|
137
|
-
else
|
|
138
|
-
usage "Unknown argument: $1"
|
|
139
|
-
fi
|
|
140
|
-
fi
|
|
141
|
-
|
|
142
|
-
while $follow; do
|
|
143
|
-
if [[ $(docker ps -q -f "name=^/solana-localnet$") ]]; then
|
|
144
|
-
(
|
|
145
|
-
set -x
|
|
146
|
-
docker logs solana-localnet -f
|
|
147
|
-
) || true
|
|
148
|
-
fi
|
|
149
|
-
sleep 1
|
|
150
|
-
done
|
|
151
|
-
|
|
152
|
-
(
|
|
153
|
-
set -x
|
|
154
|
-
docker logs solana-localnet
|
|
155
|
-
)
|
|
156
|
-
;;
|
|
157
|
-
*)
|
|
158
|
-
usage "Unknown command: $cmd"
|
|
159
|
-
esac
|
|
160
|
-
|
|
161
|
-
exit 0
|
package/bpf-sdk/LICENSE
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Copyright 2020 Solana Foundation.
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|
package/bpf-sdk/c/README.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
## Development
|
|
2
|
-
|
|
3
|
-
### Quick start
|
|
4
|
-
To get started create a `makefile` containing:
|
|
5
|
-
```make
|
|
6
|
-
include path/to/bpf.mk
|
|
7
|
-
```
|
|
8
|
-
and `src/program.c` containing:
|
|
9
|
-
```c
|
|
10
|
-
#include <solana_sdk.h>
|
|
11
|
-
|
|
12
|
-
bool entrypoint(const uint8_t *input) {
|
|
13
|
-
SolKeyedAccount ka[1];
|
|
14
|
-
uint8_t *data;
|
|
15
|
-
uint64_t data_len;
|
|
16
|
-
|
|
17
|
-
if (!sol_deserialize(buf, ka, SOL_ARRAY_SIZE(ka), NULL, &data, &data_len)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
print_params(1, ka, data, data_len);
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then run `make` to build `out/program.o`.
|
|
26
|
-
Run `make help` for more details.
|
|
27
|
-
|
|
28
|
-
### Unit tests
|
|
29
|
-
Built-in support for unit testing is provided by the
|
|
30
|
-
[Criterion](https://criterion.readthedocs.io/en/master/index.html) test framework.
|
|
31
|
-
To get started create the file `test/example.c` containing:
|
|
32
|
-
```c
|
|
33
|
-
#include <criterion/criterion.h>
|
|
34
|
-
#include "../src/program.c"
|
|
35
|
-
|
|
36
|
-
Test(test_suite_name, test_case_name) {
|
|
37
|
-
cr_assert(true);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
Then run `make test`.
|
|
41
|
-
|
|
42
|
-
### Limitations
|
|
43
|
-
* Programs must be fully contained within a single .c file
|
|
44
|
-
* No libc is available but `solana_sdk.h` provides a minimal set of primitives
|
package/bpf-sdk/c/bpf.ld
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
PHDRS
|
|
2
|
-
{
|
|
3
|
-
text PT_LOAD ;
|
|
4
|
-
rodata PT_LOAD ;
|
|
5
|
-
dynamic PT_DYNAMIC ;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
SECTIONS
|
|
9
|
-
{
|
|
10
|
-
. = SIZEOF_HEADERS;
|
|
11
|
-
.text : { *(.text*) } :text
|
|
12
|
-
.rodata : { *(.rodata*) } :rodata
|
|
13
|
-
.dynamic : { *(.dynamic) } :dynamic
|
|
14
|
-
.data.rel.ro : { *(.data.rel.ro*) } :dynamic
|
|
15
|
-
.dynsym : { *(.dynsym) } :dynamic
|
|
16
|
-
.dynstr : { *(.dynstr) } :dynamic
|
|
17
|
-
.gnu.hash : { *(.gnu.hash) } :dynamic
|
|
18
|
-
.rel.dyn : { *(.rel.dyn) } :dynamic
|
|
19
|
-
.hash : { *(.hash) } :dynamic
|
|
20
|
-
}
|