@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.
Files changed (81) hide show
  1. package/README.md +10 -55
  2. package/lib/index.browser.esm.js +48 -24
  3. package/lib/index.browser.esm.js.map +1 -1
  4. package/lib/index.cjs.js +101 -56
  5. package/lib/index.cjs.js.map +1 -1
  6. package/lib/index.esm.js +88 -64
  7. package/lib/index.esm.js.map +1 -1
  8. package/lib/index.iife.js +42 -25
  9. package/lib/index.iife.js.map +1 -1
  10. package/lib/index.iife.min.js +2 -2
  11. package/lib/index.iife.min.js.map +1 -1
  12. package/lib/types/index.d.ts.map +1 -1
  13. package/package.json +27 -45
  14. package/src/message.ts +9 -12
  15. package/src/transaction.ts +2 -2
  16. package/src/util/guarded-array-utils.ts +37 -0
  17. package/src/validator-info.ts +5 -4
  18. package/bin/bpf-sdk-install.sh +0 -38
  19. package/bin/localnet.sh +0 -161
  20. package/bpf-sdk/LICENSE +0 -13
  21. package/bpf-sdk/c/README.md +0 -44
  22. package/bpf-sdk/c/bpf.ld +0 -20
  23. package/bpf-sdk/c/bpf.mk +0 -249
  24. package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
  25. package/bpf-sdk/c/inc/solana_sdk.h +0 -669
  26. package/bpf-sdk/c/inc/stdio.h +0 -4
  27. package/bpf-sdk/c/inc/stdlib.h +0 -2
  28. package/bpf-sdk/c/inc/string.h +0 -7
  29. package/bpf-sdk/c/inc/sys/param.h +0 -1
  30. package/bpf-sdk/c/inc/wchar.h +0 -1
  31. package/bpf-sdk/env.sh +0 -39
  32. package/bpf-sdk/rust/bpf.ld +0 -20
  33. package/bpf-sdk/rust/build.sh +0 -21
  34. package/bpf-sdk/rust/clean.sh +0 -17
  35. package/bpf-sdk/rust/xargo-build.sh +0 -29
  36. package/bpf-sdk/scripts/dump.sh +0 -45
  37. package/bpf-sdk/scripts/install.sh +0 -178
  38. package/bpf-sdk/scripts/objcopy.sh +0 -6
  39. package/bpf-sdk/scripts/package.sh +0 -19
  40. package/bpf-sdk/scripts/strip.sh +0 -23
  41. package/bpf-sdk/version.txt +0 -2
  42. package/doc/assets/css/main.css +0 -2660
  43. package/doc/assets/images/icons.png +0 -0
  44. package/doc/assets/images/icons@2x.png +0 -0
  45. package/doc/assets/images/widgets.png +0 -0
  46. package/doc/assets/images/widgets@2x.png +0 -0
  47. package/doc/assets/js/main.js +0 -248
  48. package/doc/assets/js/search.js +0 -1
  49. package/doc/classes/account.html +0 -244
  50. package/doc/classes/authorized.html +0 -234
  51. package/doc/classes/bpfloader.html +0 -267
  52. package/doc/classes/connection.html +0 -2354
  53. package/doc/classes/loader.html +0 -275
  54. package/doc/classes/lockup.html +0 -250
  55. package/doc/classes/message.html +0 -326
  56. package/doc/classes/nonceaccount.html +0 -233
  57. package/doc/classes/publickey.html +0 -411
  58. package/doc/classes/secp256k1program.html +0 -308
  59. package/doc/classes/stakeinstruction.html +0 -403
  60. package/doc/classes/stakeprogram.html +0 -503
  61. package/doc/classes/systeminstruction.html +0 -563
  62. package/doc/classes/systemprogram.html +0 -503
  63. package/doc/classes/transaction.html +0 -688
  64. package/doc/classes/transactioninstruction.html +0 -240
  65. package/doc/classes/validatorinfo.html +0 -279
  66. package/doc/classes/voteaccount.html +0 -331
  67. package/doc/index.html +0 -640
  68. package/doc/interfaces/feecalculator.html +0 -166
  69. package/doc/modules.html +0 -4682
  70. package/examples/README.md +0 -10
  71. package/examples/account.html +0 -24
  72. package/examples/account.js +0 -10
  73. package/examples/bpf-c-noop/.gitignore +0 -1
  74. package/examples/bpf-c-noop/makefile +0 -1
  75. package/examples/bpf-c-noop/src/noop/noop.c +0 -19
  76. package/examples/bpf-rust-noop/.gitignore +0 -3
  77. package/examples/bpf-rust-noop/Cargo.toml +0 -23
  78. package/examples/bpf-rust-noop/Xargo.toml +0 -2
  79. package/examples/bpf-rust-noop/src/lib.rs +0 -70
  80. package/examples/get-balance.html +0 -37
  81. package/examples/get-balance.js +0 -18
package/bpf-sdk/c/bpf.mk DELETED
@@ -1,249 +0,0 @@
1
- LOCAL_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
2
- INSTALL_SH := $(abspath $(LOCAL_PATH)/../scripts/install.sh)
3
-
4
- all:
5
- .PHONY: help all clean
6
-
7
- ifneq ($(V),1)
8
- _@ :=@
9
- endif
10
-
11
- INC_DIRS ?=
12
- SRC_DIR ?= ./src
13
- TEST_PREFIX ?= test_
14
- OUT_DIR ?= ./out
15
- OS := $(shell uname)
16
-
17
- LLVM_DIR = $(LOCAL_PATH)../dependencies/bpf-tools/llvm
18
- LLVM_SYSTEM_INC_DIRS := $(LLVM_DIR)/lib/clang/11.0.1/include
19
-
20
- ifdef LLVM_DIR
21
- CC := $(LLVM_DIR)/bin/clang
22
- CXX := $(LLVM_DIR)/bin/clang++
23
- LLD := $(LLVM_DIR)/bin/ld.lld
24
- OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump
25
- endif
26
-
27
- SYSTEM_INC_DIRS := \
28
- $(LOCAL_PATH)inc \
29
- $(LLVM_SYSTEM_INC_DIRS) \
30
-
31
- C_FLAGS := \
32
- -Werror \
33
- -O2 \
34
- -fno-builtin \
35
- -std=c17 \
36
- $(addprefix -isystem,$(SYSTEM_INC_DIRS)) \
37
- $(addprefix -I,$(INC_DIRS))
38
-
39
- CXX_FLAGS := \
40
- $(C_FLAGS) \
41
- -std=c++17 \
42
-
43
- BPF_C_FLAGS := \
44
- $(C_FLAGS) \
45
- -target bpf \
46
- -fPIC \
47
-
48
- BPF_CXX_FLAGS := \
49
- $(CXX_FLAGS) \
50
- -target bpf \
51
- -fPIC \
52
- -fomit-frame-pointer \
53
- -fno-exceptions \
54
- -fno-asynchronous-unwind-tables \
55
- -fno-unwind-tables \
56
-
57
- BPF_LLD_FLAGS := \
58
- -z notext \
59
- -shared \
60
- --Bdynamic \
61
- $(LOCAL_PATH)bpf.ld \
62
- --entry entrypoint \
63
-
64
- OBJ_DUMP_FLAGS := \
65
- -color \
66
- -source \
67
- -disassemble \
68
-
69
- TESTFRAMEWORK_RPATH := $(abspath $(LOCAL_PATH)../dependencies/criterion/lib)
70
- TESTFRAMEWORK_FLAGS := \
71
- -DSOL_TEST \
72
- -isystem $(LOCAL_PATH)../dependencies/criterion/include \
73
- -L $(LOCAL_PATH)../dependencies/criterion/lib \
74
- -rpath $(TESTFRAMEWORK_RPATH) \
75
- -lcriterion \
76
-
77
- MACOS_ADJUST_TEST_DYLIB := \
78
- $(if $(filter $(OS),Darwin),\
79
- $(_@)install_name_tool -change libcriterion.3.dylib $(TESTFRAMEWORK_RPATH)/libcriterion.3.dylib, \
80
- : \
81
- )
82
-
83
- TEST_C_FLAGS := \
84
- $(C_FLAGS) \
85
- $(TESTFRAMEWORK_FLAGS) \
86
-
87
- TEST_CXX_FLAGS := \
88
- $(CXX_FLAGS) \
89
- $(TESTFRAMEWORK_FLAGS) \
90
-
91
- help:
92
- @echo ''
93
- @echo 'BPF Program makefile'
94
- @echo ''
95
- @echo 'This makefile will build BPF Programs from C or C++ source files into ELFs'
96
- @echo ''
97
- @echo 'Assumptions:'
98
- @echo ' - Programs are located in the source directory: $(SRC_DIR)/<program name>'
99
- @echo ' - Programs are named by their directory name (eg. directory name:src/foo/ -> program name:foo)'
100
- @echo ' - Tests are located in their corresponding program directory and must being with "test_"'
101
- @echo ' - Output files will be placed in the directory: $(OUT_DIR)'
102
- @echo ''
103
- @echo 'User settings'
104
- @echo ' - The following setting are overridable on the command line, default values shown:'
105
- @echo ' - Show commands while building: V=1'
106
- @echo ' V=$(V)'
107
- @echo ' - List of include directories:'
108
- @echo ' INC_DIRS=$(INC_DIRS)'
109
- @echo ' - List of system include directories:'
110
- @echo ' SYSTEM_INC_DIRS=$(SYSTEM_INC_DIRS)'
111
- @echo ' - Location of source directories:'
112
- @echo ' SRC_DIR=$(SRC_DIR)'
113
- @echo ' - Location to place output files:'
114
- @echo ' OUT_DIR=$(OUT_DIR)'
115
- @echo ' - Location of LLVM:'
116
- @echo ' LLVM_DIR=$(LLVM_DIR)'
117
- @echo ''
118
- @echo 'Usage:'
119
- @echo ' - make help - This help message'
120
- @echo ' - make all - Build all the programs and tests, run the tests'
121
- @echo ' - make programs - Build all the programs'
122
- @echo ' - make tests - Build and run all tests'
123
- @echo ' - make dump_<program name> - Dumps the contents of the program to stdout'
124
- @echo ' - make <program name> - Build a single program by name'
125
- @echo ' - make <test name> - Build and run a single test by name'
126
- @echo ''
127
- @echo 'Available programs:'
128
- $(foreach name, $(PROGRAM_NAMES), @echo ' - $(name)'$(\n))
129
- @echo ''
130
- @echo 'Available tests:'
131
- $(foreach name, $(TEST_NAMES), @echo ' - $(name)'$(\n))
132
- @echo ''
133
- @echo 'Example:'
134
- @echo ' - Assuming a programed named foo (src/foo/foo.c)'
135
- @echo ' - make foo'
136
- @echo ' - make dump_foo'
137
- @echo ''
138
-
139
- define C_RULE
140
- $1: $2
141
- @echo "[cc] $1 ($2)"
142
- $(_@)mkdir -p $(dir $1)
143
- $(_@)$(CC) $(BPF_C_FLAGS) -o $1 -c $2 -MD -MF $(1:.o=.d)
144
- endef
145
-
146
- define CC_RULE
147
- $1: $2
148
- @echo "[cxx] $1 ($2)"
149
- $(_@)mkdir -p $(dir $1)
150
- $(_@)$(CXX) $(BPF_CXX_FLAGS) -o $1 -c $2 -MD -MF $(1:.o=.d)
151
- endef
152
-
153
- define O_RULE
154
- $1: $2
155
- @echo "[llc] $1 ($2)"
156
- $(_@)mkdir -p $(dir $1)
157
- $(_@)$(LLC) $(BPF_LLC_FLAGS) -o $1 $2
158
- endef
159
-
160
- define SO_RULE
161
- $1: $2
162
- @echo "[lld] $1 ($2)"
163
- $(_@)mkdir -p $(dir $1)
164
- $(_@)$(LLD) $(BPF_LLD_FLAGS) -o $1 $2
165
- ifeq (,$(wildcard $(subst .so,-keypair.json,$1)))
166
- $(_@)solana-keygen new --no-passphrase --silent -o $(subst .so,-keypair.json,$1)
167
- endif
168
- @echo To deploy this program:
169
- @echo $$$$ solana program deploy $(realpath $1)
170
- endef
171
-
172
- define TEST_C_RULE
173
- $1: $2
174
- @echo "[test cc] $1 ($2)"
175
- $(_@)mkdir -p $(dir $1)
176
- $(_@)$(CC) $(TEST_C_FLAGS) -o $1 $2 -MD -MF $(1:.o=.d)
177
- $(_@)$(MACOS_ADJUST_TEST_DYLIB) $1
178
- endef
179
-
180
- define TEST_CC_RULE
181
- $1: $2
182
- @echo "[test cxx] $1 ($2)"
183
- $(_@)mkdir -p $(dir $1)
184
- $(_@)$(CXX) $(TEST_CXX_FLAGS) -o $1 $2 -MD -MF $(1:.o=.d)
185
- $(_@)$(MACOS_ADJUST_TEST_DYLIB) $1
186
- endef
187
-
188
- define TEST_EXEC_RULE
189
- $1: $2
190
- $2$(\n)
191
- endef
192
-
193
- .PHONY: $(INSTALL_SH)
194
- $(INSTALL_SH):
195
- $(_@)$(INSTALL_SH)
196
-
197
- PROGRAM_NAMES := $(notdir $(basename $(wildcard $(SRC_DIR)/*)))
198
-
199
- define \n
200
-
201
-
202
- endef
203
-
204
- all: programs tests
205
-
206
- $(foreach PROGRAM, $(PROGRAM_NAMES), \
207
- $(eval -include $(wildcard $(OUT_DIR)/$(PROGRAM)/*.d)) \
208
- \
209
- $(eval $(PROGRAM): %: $(addprefix $(OUT_DIR)/, %.so)) \
210
- $(eval $(PROGRAM)_SRCS := \
211
- $(addprefix $(SRC_DIR)/$(PROGRAM)/, \
212
- $(filter-out $(TEST_PREFIX)%,$(notdir $(wildcard $(SRC_DIR)/$(PROGRAM)/*.c $(SRC_DIR)/$(PROGRAM)/*.cc))))) \
213
- $(eval $(PROGRAM)_OBJS := $(subst $(SRC_DIR), $(OUT_DIR), \
214
- $(patsubst %.c,%.o, \
215
- $(patsubst %.cc,%.o,$($(PROGRAM)_SRCS))))) \
216
- $(eval $($(PROGRAM)_SRCS): $(INSTALL_SH)) \
217
- $(eval $(call SO_RULE,$(OUT_DIR)/$(PROGRAM).so,$($(PROGRAM)_OBJS))) \
218
- $(foreach _,$(filter %.c,$($(PROGRAM)_SRCS)), \
219
- $(eval $(call C_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%.o)),$_))) \
220
- $(foreach _,$(filter %.cc,$($(PROGRAM)_SRCS)), \
221
- $(eval $(call CC_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%.o)),$_))) \
222
- \
223
- $(eval TESTS := $(notdir $(basename $(wildcard $(SRC_DIR)/$(PROGRAM)/$(TEST_PREFIX)*.c)))) \
224
- $(eval $(TESTS) : %: $(addprefix $(OUT_DIR)/$(PROGRAM)/, %)) \
225
- $(eval TEST_NAMES := $(TEST_NAMES) $(TESTS)) \
226
- $(foreach TEST, $(TESTS), \
227
- $(eval $(TEST)_SRCS := \
228
- $(addprefix $(SRC_DIR)/$(PROGRAM)/, \
229
- $(notdir $(wildcard $(SRC_DIR)/$(PROGRAM)/$(TEST).c $(SRC_DIR)/$(PROGRAM)/$(TEST).cc)))) \
230
- $(eval $($(TEST)_SRCS): $(INSTALL_SH)) \
231
- $(foreach _,$(filter %.c,$($(TEST)_SRCS)), \
232
- $(eval $(call TEST_C_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%)),$_))) \
233
- $(foreach _,$(filter %.cc, $($(TEST)_SRCS)), \
234
- $(eval $(call TEST_CC_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%)),$_))) \
235
- $(eval $(call TEST_EXEC_RULE,$(TEST),$(addprefix $(OUT_DIR)/$(PROGRAM)/, $(TEST)))) \
236
- ) \
237
- )
238
-
239
- .PHONY: $(PROGRAM_NAMES)
240
- programs: $(PROGRAM_NAMES)
241
-
242
- .PHONY: $(TEST_NAMES)
243
- tests: $(TEST_NAMES)
244
-
245
- dump_%: %
246
- $(_@)$(OBJ_DUMP) $(OBJ_DUMP_FLAGS) $(addprefix $(OUT_DIR)/, $(addsuffix .so, $<))
247
-
248
- clean:
249
- rm -rf $(OUT_DIR)
@@ -1,115 +0,0 @@
1
- #pragma once
2
- /**
3
- * @brief Solana bpf_loader_deprecated deserializer to used when deploying
4
- * a program with `BPFLoader1111111111111111111111111111111111`
5
- */
6
-
7
- #ifdef __cplusplus
8
- extern "C" {
9
- #endif
10
-
11
- /**
12
- * De-serializes the input parameters into usable types
13
- *
14
- * Use this function to deserialize the buffer passed to the program entrypoint
15
- * into usable types. This function does not perform copy deserialization,
16
- * instead it populates the pointers and lengths in SolAccountInfo and data so
17
- * that any modification to lamports or account data take place on the original
18
- * buffer. Doing so also eliminates the need to serialize back into the buffer
19
- * at the end of the program.
20
- *
21
- * @param input Source buffer containing serialized input parameters
22
- * @param params Pointer to a SolParameters structure
23
- * @return Boolean true if successful.
24
- */
25
- static bool sol_deserialize_deprecated(
26
- const uint8_t *input,
27
- SolParameters *params,
28
- uint64_t ka_num
29
- ) {
30
- if (NULL == input || NULL == params) {
31
- return false;
32
- }
33
- params->ka_num = *(uint64_t *) input;
34
- input += sizeof(uint64_t);
35
-
36
- for (int i = 0; i < params->ka_num; i++) {
37
- uint8_t dup_info = input[0];
38
- input += sizeof(uint8_t);
39
-
40
- if (i >= ka_num) {
41
- if (dup_info == UINT8_MAX) {
42
- input += sizeof(uint8_t);
43
- input += sizeof(uint8_t);
44
- input += sizeof(SolPubkey);
45
- input += sizeof(uint64_t);
46
- input += *(uint64_t *) input;
47
- input += sizeof(uint64_t);
48
- input += sizeof(SolPubkey);
49
- input += sizeof(uint8_t);
50
- input += sizeof(uint64_t);
51
- }
52
- continue;
53
- }
54
- if (dup_info == UINT8_MAX) {
55
- // is signer?
56
- params->ka[i].is_signer = *(uint8_t *) input != 0;
57
- input += sizeof(uint8_t);
58
-
59
- // is writable?
60
- params->ka[i].is_writable = *(uint8_t *) input != 0;
61
- input += sizeof(uint8_t);
62
-
63
- // key
64
- params->ka[i].key = (SolPubkey *) input;
65
- input += sizeof(SolPubkey);
66
-
67
- // lamports
68
- params->ka[i].lamports = (uint64_t *) input;
69
- input += sizeof(uint64_t);
70
-
71
- // account data
72
- params->ka[i].data_len = *(uint64_t *) input;
73
- input += sizeof(uint64_t);
74
- params->ka[i].data = (uint8_t *) input;
75
- input += params->ka[i].data_len;
76
-
77
- // owner
78
- params->ka[i].owner = (SolPubkey *) input;
79
- input += sizeof(SolPubkey);
80
-
81
- // executable?
82
- params->ka[i].executable = *(uint8_t *) input;
83
- input += sizeof(uint8_t);
84
-
85
- // rent epoch
86
- params->ka[i].rent_epoch = *(uint64_t *) input;
87
- input += sizeof(uint64_t);
88
- } else {
89
- params->ka[i].is_signer = params->ka[dup_info].is_signer;
90
- params->ka[i].key = params->ka[dup_info].key;
91
- params->ka[i].lamports = params->ka[dup_info].lamports;
92
- params->ka[i].data_len = params->ka[dup_info].data_len;
93
- params->ka[i].data = params->ka[dup_info].data;
94
- params->ka[i].owner = params->ka[dup_info].owner;
95
- params->ka[i].executable = params->ka[dup_info].executable;
96
- params->ka[i].rent_epoch = params->ka[dup_info].rent_epoch;
97
- }
98
- }
99
-
100
- params->data_len = *(uint64_t *) input;
101
- input += sizeof(uint64_t);
102
- params->data = input;
103
- input += params->data_len;
104
-
105
- params->program_id = (SolPubkey *) input;
106
- input += sizeof(SolPubkey);
107
-
108
- return true;
109
- }
110
-
111
- #ifdef __cplusplus
112
- }
113
- #endif
114
-
115
- /**@}*/