@solana/instructions 2.0.0-experimental.b8df7b4
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/LICENSE +20 -0
- package/README.md +58 -0
- package/dist/index.browser.cjs +4 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +3 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.development.js +8 -0
- package/dist/index.development.js.map +1 -0
- package/dist/index.native.js +3 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.node.cjs +4 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.js +3 -0
- package/dist/index.node.js.map +1 -0
- package/dist/index.production.min.js +6 -0
- package/dist/types/accounts.d.ts +35 -0
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instruction.d.ts +14 -0
- package/dist/types/instruction.d.ts.map +1 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2018 Solana Labs, Inc
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[![npm][npm-image]][npm-url]
|
|
2
|
+
[![npm-downloads][npm-downloads-image]][npm-url]
|
|
3
|
+
[![semantic-release][semantic-release-image]][semantic-release-url]
|
|
4
|
+
<br />
|
|
5
|
+
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
|
|
6
|
+
|
|
7
|
+
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
|
8
|
+
[code-style-prettier-url]: https://github.com/prettier/prettier
|
|
9
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/instructions/experimental.svg?style=flat
|
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/instructions/experimental.svg?style=flat
|
|
11
|
+
[npm-url]: https://www.npmjs.com/package/@solana/instructions/v/experimental
|
|
12
|
+
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
|
13
|
+
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
14
|
+
|
|
15
|
+
# @solana/instructions
|
|
16
|
+
|
|
17
|
+
This package contains types for creating transaction instructions. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
|
|
18
|
+
|
|
19
|
+
## Types
|
|
20
|
+
|
|
21
|
+
### `IAccountMeta<TAddress>`
|
|
22
|
+
|
|
23
|
+
This type represents an account's address and metadata about its mutability and whether it must be a signer of the transaction.
|
|
24
|
+
|
|
25
|
+
Typically, you will use one of its subtypes.
|
|
26
|
+
|
|
27
|
+
| | `isSigner` | `isWritable` |
|
|
28
|
+
| --------------------------------- | ---------- | ------------ |
|
|
29
|
+
| `ReadonlyAccount<TAddress>` | ❌ | ❌ |
|
|
30
|
+
| `WritableAccount<TAddress>` | ❌ | ✅ |
|
|
31
|
+
| `ReadonlySignerAccount<TAddress>` | ✅ | ❌ |
|
|
32
|
+
| `WritableSignerAccount<TAddress>` | ✅ | ✅ |
|
|
33
|
+
|
|
34
|
+
For example, you could type the rent sysvar account like this:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
type RentSysvar = ReadonlyAccount<'SysvarRent111111111111111111111111111111111'>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### `Instruction<TProgramAddress, TAccounts, TData>`
|
|
41
|
+
|
|
42
|
+
Use this to define the structure of a transaction instruction.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type InitializeStakeInstruction = Instruction<
|
|
46
|
+
// Program address
|
|
47
|
+
'StakeConfig11111111111111111111111111111111',
|
|
48
|
+
// Accounts
|
|
49
|
+
[
|
|
50
|
+
WritableAccount, // Stake account
|
|
51
|
+
RentSysvar
|
|
52
|
+
],
|
|
53
|
+
// Data
|
|
54
|
+
InitializeStakeInstructionData
|
|
55
|
+
>;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Instructions that do not require data may omit the `TData` type parameter.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Base58EncodedAddress } from '@solana/keys';
|
|
2
|
+
export interface IAccountMeta<TAddress extends string = string> {
|
|
3
|
+
readonly address: Base58EncodedAddress<TAddress>;
|
|
4
|
+
readonly isSigner: boolean;
|
|
5
|
+
readonly isWritable: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type ReadonlyAccount<TAddress extends string = string> = IAccountMeta<TAddress> & Readonly<{
|
|
8
|
+
isSigner: false;
|
|
9
|
+
isWritable: false;
|
|
10
|
+
}>;
|
|
11
|
+
export type WritableAccount<TAddress extends string = string> = IAccountMeta<TAddress> & Readonly<{
|
|
12
|
+
isSigner: false;
|
|
13
|
+
isWritable: true;
|
|
14
|
+
}>;
|
|
15
|
+
export type ReadonlySignerAccount<TAddress extends string = string> = IAccountMeta<TAddress> & Readonly<{
|
|
16
|
+
isSigner: true;
|
|
17
|
+
isWritable: false;
|
|
18
|
+
}>;
|
|
19
|
+
export type WritableSignerAccount<TAddress extends string = string> = IAccountMeta<TAddress> & Readonly<{
|
|
20
|
+
isSigner: true;
|
|
21
|
+
isWritable: true;
|
|
22
|
+
}>;
|
|
23
|
+
export interface IAccountLookupMeta<TAddress extends string = string, TLookupTableAddress extends string = string> {
|
|
24
|
+
readonly address: Base58EncodedAddress<TAddress>;
|
|
25
|
+
readonly addressIndex: number;
|
|
26
|
+
readonly lookupTableAddress: Base58EncodedAddress<TLookupTableAddress>;
|
|
27
|
+
readonly isWritable: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type ReadonlyAccountLookup<TAddress extends string = string, TLookupTableAddress extends string = string> = IAccountLookupMeta<TAddress, TLookupTableAddress> & Readonly<{
|
|
30
|
+
isWritable: false;
|
|
31
|
+
}>;
|
|
32
|
+
export type WritableAccountLookup<TAddress extends string = string, TLookupTableAddress extends string = string> = IAccountLookupMe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A;CAAE,CAAC,CAAC;AAEnD,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,mBAAmB,SAAS,MAAM,GAAG,MAAM;IAC7G,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;IACvE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,qBAAqB,CAC7B,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,mBAAmB,SAAS,MAAM,GAAG,MAAM,IAC3C,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC;IAAE,UAAU,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AACxF,MAAM,MAAM,qBAAqB,CAC7B,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,mBAAmB,SAAS,MAAM,GAAG,MAAM,IAC3C,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Base58EncodedAddress } from '@solana/keys';
|
|
2
|
+
import { IAccountLookupMeta, IAccountMeta } from './accounts';
|
|
3
|
+
export interface IInstruction<TProgramAddress extends string = string> {
|
|
4
|
+
readonly accounts?: readonly (IAccountMeta | IAccountLookupMeta)[];
|
|
5
|
+
readonly data?: Uint8Array;
|
|
6
|
+
readonly programAddress: Base58EncodedAddress<TProgramAddress>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]> extends IInstruction {
|
|
9
|
+
readonly accounts: TAccounts;
|
|
10
|
+
}
|
|
11
|
+
export interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {
|
|
12
|
+
readonly data: TData;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=instruction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../src/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,WAAW,YAAY,CAAC,eAAe,SAAS,MAAM,GAAG,MAAM;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE,CAAC;IACnE,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,wBAAwB,CAAC,SAAS,SAAS,SAAS,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE,CACtG,SAAQ,YAAY;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,UAAU,CAAE,SAAQ,YAAY;IAChF,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solana/instructions",
|
|
3
|
+
"version": "2.0.0-experimental.b8df7b4",
|
|
4
|
+
"description": "Helpers for creating transaction instructions",
|
|
5
|
+
"exports": {
|
|
6
|
+
"browser": {
|
|
7
|
+
"import": "./dist/index.browser.js",
|
|
8
|
+
"require": "./dist/index.browser.cjs"
|
|
9
|
+
},
|
|
10
|
+
"node": {
|
|
11
|
+
"import": "./dist/index.node.js",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"react-native": "./dist/index.native.js",
|
|
15
|
+
"types": "./dist/types/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
19
|
+
"./dist/index.node.js": "./dist/index.browser.js"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.node.cjs",
|
|
22
|
+
"module": "./dist/index.node.js",
|
|
23
|
+
"react-native": "./dist/index.native.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"files": [
|
|
27
|
+
"./dist/"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"keywords": [
|
|
31
|
+
"blockchain",
|
|
32
|
+
"solana",
|
|
33
|
+
"web3"
|
|
34
|
+
],
|
|
35
|
+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/solana-labs/solana-web3.js"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "http://github.com/solana-labs/solana-web3.js/issues"
|
|
43
|
+
},
|
|
44
|
+
"browserslist": [
|
|
45
|
+
"supports bigint and not dead",
|
|
46
|
+
"maintained node versions"
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@solana/eslint-config-solana": "^1.0.0",
|
|
50
|
+
"@swc/core": "^1.3.18",
|
|
51
|
+
"@swc/jest": "^0.2.23",
|
|
52
|
+
"@types/jest": "^29.5.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
54
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
55
|
+
"agadoo": "^3.0.0",
|
|
56
|
+
"eslint": "^8.37.0",
|
|
57
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
58
|
+
"jest": "^29.5.0",
|
|
59
|
+
"jest-runner-eslint": "^2.0.0",
|
|
60
|
+
"jest-runner-prettier": "^1.0.0",
|
|
61
|
+
"postcss": "^8.4.12",
|
|
62
|
+
"prettier": "^2.7.1",
|
|
63
|
+
"ts-node": "^10.9.1",
|
|
64
|
+
"tsup": "6.7.0",
|
|
65
|
+
"typescript": "^5.0.3",
|
|
66
|
+
"version-from-git": "^1.1.1",
|
|
67
|
+
"@solana/keys": "2.0.0-development",
|
|
68
|
+
"build-scripts": "0.0.0",
|
|
69
|
+
"test-config": "0.0.0",
|
|
70
|
+
"tsconfig": "0.0.0"
|
|
71
|
+
},
|
|
72
|
+
"bundlewatch": {
|
|
73
|
+
"defaultCompression": "gzip",
|
|
74
|
+
"files": [
|
|
75
|
+
{
|
|
76
|
+
"path": "./dist/index*.js"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
82
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
83
|
+
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
|
|
84
|
+
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
|
|
85
|
+
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
|
|
86
|
+
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
|
|
87
|
+
"test:treeshakability:browser": "agadoo dist/index.browser.js",
|
|
88
|
+
"test:treeshakability:native": "agadoo dist/index.node.js",
|
|
89
|
+
"test:treeshakability:node": "agadoo dist/index.native.js",
|
|
90
|
+
"test:typecheck": "tsc --noEmit"
|
|
91
|
+
}
|
|
92
|
+
}
|