Compare commits

...

413 Commits

Author SHA1 Message Date
Trent Nelson 7d00fe08a4
token-cli: Bump version to 2.0.13 2021-07-13 00:37:26 -06:00
Sebastian Bor 4f2a8dbb30
Governance: Move realm and goverend_account from config to direct field (#2060)
* chore: move realm from config to governance account direct field

* chore: move governed_account from config to governance account direct field

* chore: update comments

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-12 15:38:58 +01:00
Jon Cinque 151eef0696
Convert `checked_add` to `saturating_add` to fix downstream build (#2055) 2021-07-12 12:50:28 +02:00
dependabot[bot] b2980424df
build(deps-dev): bump ts-node from 10.0.0 to 10.1.0 in /token-swap/js (#2068)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.0.0 to 10.1.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.0.0...v10.1.0)

---
updated-dependencies:
- dependency-name: ts-node
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 10:14:43 +00:00
dependabot[bot] 9bc9fbb43b
build(deps-dev): bump @types/node in /token-lending/js (#2067)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.3.0 to 16.3.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 09:39:23 +00:00
dependabot[bot] ecdea03d6c
build(deps-dev): bump typedoc from 0.21.2 to 0.21.4 in /token-lending/js (#2066)
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.21.2 to 0.21.4.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.21.2...v0.21.4)

---
updated-dependencies:
- dependency-name: typedoc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 09:30:48 +00:00
dependabot[bot] 981af029e0
build(deps-dev): bump ts-node from 10.0.0 to 10.1.0 in /token-lending/js (#2065)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.0.0 to 10.1.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.0.0...v10.1.0)

---
updated-dependencies:
- dependency-name: ts-node
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 09:28:35 +00:00
dependabot[bot] ee0c91d0ab
build(deps-dev): bump rollup from 2.52.8 to 2.53.1 in /token-lending/js (#2064)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.8 to 2.53.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.8...v2.53.1)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 08:42:12 +00:00
dependabot[bot] 2ffb7d2dc3
build(deps-dev): bump flow-remove-types in /token/js (#2063)
Bumps [flow-remove-types](https://github.com/facebook/flow) from 2.154.0 to 2.155.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/commits)

---
updated-dependencies:
- dependency-name: flow-remove-types
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 08:42:06 +00:00
dependabot[bot] 4badd9795c
build(deps-dev): bump rollup from 2.53.0 to 2.53.1 in /token/js (#2062)
Bumps [rollup](https://github.com/rollup/rollup) from 2.53.0 to 2.53.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.53.0...v2.53.1)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-12 08:13:27 +00:00
Sebastian Bor 28928eaec2
Governance: SetGovernanceConfig instruction (#2039)
* feat: implement set_governance_config instruction

* chore: add authority error tests

* chore: rename with_instruction methods

* chore: add invalid config tests

* chore: code cleanup

* chore: cleanup test
2021-07-10 11:19:22 +01:00
Jon Cinque 054d61c6b2
stake-pool: Increase version for crate release, update program id (#2059) 2021-07-10 00:24:24 +02:00
Jon Cinque f35ca3c48c
stake-pool-cli: Address feedback (#2057)
* Fix signer parameters (staker, manager, depositor, fee-payer, and
  token-owner)
* On deposit / withdraw / add / remove validator, show the validator
  stake account and where the stake is going to
2021-07-09 23:56:41 +02:00
Michael Vines b209d4ddc5 Bump spl-name-service version to 0.1.1 2021-07-09 08:44:17 -07:00
dependabot[bot] 5c95669d2d
build(deps-dev): bump flow-bin from 0.154.0 to 0.155.0 in /token-swap/js (#2054)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.154.0 to 0.155.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

---
updated-dependencies:
- dependency-name: flow-bin
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 10:34:55 +00:00
dependabot[bot] fce0d9da42
build(deps-dev): bump @types/node in /token-lending/js (#2053)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.0.1 to 16.3.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 10:34:49 +00:00
dependabot[bot] d2dddbfb04
build(deps): bump @solana/web3.js in /token-swap/js (#2052)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.20.0 to 1.20.2.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.20.0...v1.20.2)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 10:14:27 +00:00
dependabot[bot] 33244bb00a
build(deps-dev): bump @solana/web3.js in /token-lending/js (#2051)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.20.0 to 1.20.2.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.20.0...v1.20.2)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 10:12:48 +00:00
dependabot[bot] ad00d7b70c
build(deps): bump @solana/web3.js from 1.20.0 to 1.20.2 in /token/js (#2049)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.20.0 to 1.20.2.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.20.0...v1.20.2)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 09:57:07 +00:00
dependabot[bot] b160adcf83
build(deps-dev): bump rollup from 2.52.8 to 2.53.0 in /token/js (#2048)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.8 to 2.53.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.8...v2.53.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 08:52:08 +00:00
dependabot[bot] f7e78c4e93
build(deps-dev): bump flow-bin from 0.154.0 to 0.155.0 in /token/js (#2047)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.154.0 to 0.155.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

---
updated-dependencies:
- dependency-name: flow-bin
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-09 08:13:07 +00:00
Jon Cinque 99a6e95106
stake-pool: Optimizations for 4k validators (#2041)
* In-place serde

* Add cleanup instruction

* Add BigVec tests, clarify lifetimes
2021-07-08 22:50:28 +02:00
Hao-Cher Hong 8734338d57 spl-token docs: Create NFT token with 0 decimal place
Close #2040
2021-07-08 12:56:02 -07:00
dependabot[bot] e1da594811
build(deps-dev): bump start-server-and-test in /token-swap/js (#2044)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.5 to 1.12.6.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.5...v1.12.6)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-08 10:13:30 +00:00
dependabot[bot] c09a680abe
build(deps-dev): bump @types/prettier in /token-lending/js (#2043)
Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier)

---
updated-dependencies:
- dependency-name: "@types/prettier"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-08 09:46:56 +00:00
dependabot[bot] 1daf6eebf2
build(deps-dev): bump @types/node in /token-lending/js (#2042)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.0.0 to 16.0.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-08 09:44:50 +00:00
Sebastian Bor cf4b264c3d
Governance: future proofing for v2 (#2002)
* chore: upgrade instruction serialisation

* chore: add assert for base64 encoded instruction

* chore: move fields with dynamic size to account  end

* chore: Add VoteThresholdPercentageType to support quorum votes in future versions

* chore: Add VoteWeightSource to support account snapshots as voter weights in future versions

* chore: Add InstructionExecutionStatus to support failing proposal instructions in future versions

* fix: update voting_at_slot when proposal enters voting state

* fix: change min_tokens_to_create_proposal to u64 to support large mints

* chore: add InstructionExecutionFlags to support ordered and transactional instruction in future versions

* chore: add withdraw tests with relinquished and unrelinquished votes

* chore: add placeholder for proposal_cool_off_time

* chore: add padding to permanent accounts to use in future versions

* chore: add ProposalCoolOffTimeNotSupported error

* chore: start governance errors from 500

* chore: update versions

* chore: update comments

* chore: use slice for reserved account space

* chore: use VoteThresholdPercentage enum to store percentage value

* chore: use enum None value instead of Option for execution_status

* chore: use enum None instead of Option for execution_flags

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-07 14:43:31 +01:00
dependabot[bot] 299b39e0e3
build(deps): bump buffer-layout from 1.2.1 to 1.2.2 in /token-swap/js (#2038)
Bumps [buffer-layout](https://github.com/pabigot/buffer-layout) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/pabigot/buffer-layout/releases)
- [Changelog](https://github.com/pabigot/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pabigot/buffer-layout/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: buffer-layout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-07 10:11:58 +00:00
dependabot[bot] 5be5e2431f
build(deps-dev): bump rollup from 2.52.7 to 2.52.8 in /token-lending/js (#2037)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.7 to 2.52.8.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.7...v2.52.8)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-07 10:02:04 +00:00
dependabot[bot] 8086344e5e
build(deps-dev): bump rollup from 2.52.7 to 2.52.8 in /token/js (#2035)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.7 to 2.52.8.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.7...v2.52.8)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-07 08:11:41 +00:00
Trent Nelson 7b5afeac8d token-cli: Dedupe 'transfer' help message --owner value name 2021-07-06 20:37:55 +00:00
dependabot[bot] e8b555f69d
build(deps-dev): bump @typescript-eslint/parser in /token/js (#2032)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.1 to 4.28.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.2/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 10:00:27 +00:00
dependabot[bot] 409cdfd593
build(deps-dev): bump @typescript-eslint/eslint-plugin (#2030)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.28.1 to 4.28.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.2/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 09:47:01 +00:00
dependabot[bot] 2bc4f0b91f
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#2031)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.1 to 4.28.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.2/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 09:46:56 +00:00
dependabot[bot] 00772220da
build(deps): bump buffer-layout from 1.2.1 to 1.2.2 in /token-lending/js (#2029)
Bumps [buffer-layout](https://github.com/pabigot/buffer-layout) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/pabigot/buffer-layout/releases)
- [Changelog](https://github.com/pabigot/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pabigot/buffer-layout/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: buffer-layout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 09:45:39 +00:00
dependabot[bot] 32cb81bce1
build(deps-dev): bump start-server-and-test in /token/js (#2028)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.5 to 1.12.6.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.5...v1.12.6)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 09:29:52 +00:00
dependabot[bot] 7dbdffc93c
build(deps): bump buffer-layout from 1.2.1 to 1.2.2 in /token/js (#2027)
Bumps [buffer-layout](https://github.com/pabigot/buffer-layout) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/pabigot/buffer-layout/releases)
- [Changelog](https://github.com/pabigot/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pabigot/buffer-layout/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: buffer-layout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 08:34:31 +00:00
dependabot[bot] e666395b9d
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#2026)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.28.1 to 4.28.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.2/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-06 08:15:21 +00:00
dependabot[bot] 6b31bec842
build(deps-dev): bump eslint from 7.29.0 to 7.30.0 in /token-swap/js (#2024)
Bumps [eslint](https://github.com/eslint/eslint) from 7.29.0 to 7.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.29.0...v7.30.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 10:14:15 +00:00
dependabot[bot] cbf2e9d978
build(deps-dev): bump eslint from 7.29.0 to 7.30.0 in /token-lending/js (#2022)
Bumps [eslint](https://github.com/eslint/eslint) from 7.29.0 to 7.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.29.0...v7.30.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 09:54:05 +00:00
dependabot[bot] afb8272496
build(deps-dev): bump @types/node in /token-lending/js (#2023)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.14.0 to 16.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 09:41:28 +00:00
dependabot[bot] dfb5774bd2
build(deps-dev): bump eslint from 7.29.0 to 7.30.0 in /token/js (#2021)
Bumps [eslint](https://github.com/eslint/eslint) from 7.29.0 to 7.30.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.29.0...v7.30.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 09:30:12 +00:00
dependabot[bot] 2ada2d768d
build(deps-dev): bump rollup from 2.52.4 to 2.52.7 in /token/js (#2020)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.4 to 2.52.7.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.4...v2.52.7)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 08:37:59 +00:00
dependabot[bot] 90883b6b04
build(deps-dev): bump mocha from 9.0.0 to 9.0.2 in /token/js (#2019)
Bumps [mocha](https://github.com/mochajs/mocha) from 9.0.0 to 9.0.2.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v9.0.0...v9.0.2)

---
updated-dependencies:
- dependency-name: mocha
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 08:14:45 +00:00
Jordan Sexton 3f675317bb
lending/js: fix unintentional recursion (#2018)
* bind to layout

* version bump: 0.3.4
2021-07-02 17:05:31 -05:00
dependabot[bot] 73e4e0c533
build(deps): bump enum_dispatch from 0.3.5 to 0.3.7 (#2017)
Bumps [enum_dispatch](https://gitlab.com/antonok/enum_dispatch) from 0.3.5 to 0.3.7.
- [Release notes](https://gitlab.com/antonok/enum_dispatch/tags)
- [Changelog](https://gitlab.com/antonok/enum_dispatch/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/antonok/enum_dispatch/commits/master)

---
updated-dependencies:
- dependency-name: enum_dispatch
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-02 17:52:01 +00:00
Tyera Eulberg 0acc8c8bad
Bump solana and borsh crates (#2015) 2021-07-02 16:53:41 +00:00
dependabot[bot] 54ae09cf8a
build(deps-dev): bump rollup from 2.52.6 to 2.52.7 in /token-lending/js (#2014)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.6 to 2.52.7.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.6...v2.52.7)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-02 09:54:26 +00:00
Jordan Sexton b763572c4f
lending: fixing CI test (#2013)
* lending: use yarn instead of npm to build
2021-07-01 21:46:05 -05:00
Jordan Sexton ba0c0e007f
lending: js fixes (#2012) 2021-07-01 21:04:54 -05:00
jordansexton fe57f29225 lint fix 2021-07-01 18:20:24 -05:00
Jordan Sexton aacb0b7c09
lending: JavaScript / TypeScript client library (#1996) 2021-07-01 18:10:56 -05:00
Haik Dulgarian 5022f8bc54
Fix a variety of token.md doc inconsistencies; improve multi-sign nonce example (#1993)
* test improved markdown for spl-token

* test improved markdown for spl-token

* test improved markdown for spl-token

* test improved markdown for spl-token

* test improved markdown for spl-token

* test improved markdown for spl-token

* test improved markdown for spl-token

* finalize formatting of console commands and improve nonce account example

* finalize formatting of console commands and improve nonce account example

Co-authored-by: Haskell FTW <HaskellFTW@protonmail.com>
2021-07-01 18:57:33 +02:00
Lcchy c05f445d73
Minor fixes in name-service (#1895)
* Fix reverse twitter registries and program space allocation

* Small fixes and address update

* Fix the package name
2021-07-01 11:46:32 -05:00
dependabot[bot] 81f0b9a7a0
build(deps): bump thiserror from 1.0.24 to 1.0.25 (#2010)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.24...1.0.25)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 12:25:01 +00:00
dependabot[bot] c98e05fe37
build(deps): bump roots from 0.0.6 to 0.0.7 (#2009)
Bumps [roots](https://github.com/vorot/roots) from 0.0.6 to 0.0.7.
- [Release notes](https://github.com/vorot/roots/releases)
- [Changelog](https://github.com/vorot/roots/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vorot/roots/compare/v0.0.6...v0.0.7)

---
updated-dependencies:
- dependency-name: roots
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 12:11:43 +00:00
dependabot[bot] b565332024
build(deps): bump serde from 1.0.125 to 1.0.126 (#2008)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.125 to 1.0.126.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.125...v1.0.126)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 11:57:51 +00:00
dependabot[bot] 2cb2129527
build(deps): bump proptest from 0.10.1 to 1.0.0 (#2007)
Bumps [proptest](https://github.com/altsysrq/proptest) from 0.10.1 to 1.0.0.
- [Release notes](https://github.com/altsysrq/proptest/releases)
- [Changelog](https://github.com/AltSysrq/proptest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/altsysrq/proptest/compare/v0.10.1...1.0.0)

---
updated-dependencies:
- dependency-name: proptest
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 11:44:21 +00:00
dependabot[bot] 99654e0ad8
build(deps): bump uint from 0.8.5 to 0.9.1 (#2006)
Bumps [uint](https://github.com/paritytech/parity-common) from 0.8.5 to 0.9.1.
- [Release notes](https://github.com/paritytech/parity-common/releases)
- [Commits](https://github.com/paritytech/parity-common/compare/uint-v0.8.5...uint-v0.9.1)

---
updated-dependencies:
- dependency-name: uint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 11:31:18 +00:00
dependabot[bot] 42d165efcd
build(deps-dev): bump typescript from 4.3.4 to 4.3.5 in /token-swap/js (#2005)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.4 to 4.3.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.4...v4.3.5)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 11:03:09 +00:00
Jon Cinque 8f2c8fa6c8
stake-pool-cli: Add small optimizations for updating faster (#1995)
* stake-pool-cli: Add small optimizations for updating faster

* Cargo fmt

* Light refactor

* Refactor transaction creation / checking

* Rename function
2021-06-30 12:59:23 +02:00
dependabot[bot] 38f87dcae8
build(deps-dev): bump rollup from 2.52.3 to 2.52.4 in /token/js (#2000)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.3 to 2.52.4.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.3...v2.52.4)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-30 08:40:03 +00:00
dependabot[bot] ec3202de8b
build(deps-dev): bump eslint-plugin-flowtype in /token/js (#1999)
Bumps [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype) from 5.7.2 to 5.8.0.
- [Release notes](https://github.com/gajus/eslint-plugin-flowtype/releases)
- [Commits](https://github.com/gajus/eslint-plugin-flowtype/compare/v5.7.2...v5.8.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-flowtype
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-30 08:29:19 +00:00
dependabot[bot] 858e6c3592
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1998)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.0 to 4.28.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-30 08:12:46 +00:00
Sebastian Bor 775e536842
Governance: Change timestamps and time periods to UnixTimestamp (#1984)
* feat: change signing_off_at and closed_at to UnixTimestamp

* feat: change executing_at to UnixTimestamp

* feat: change voting_at and voting_completed_at to UnixTimestamp

* feat: change draft_at to UnixTimestamp

* chore: cleanup slot/timestamp comments

* chore: fix merge conflicts
2021-06-29 23:03:09 +01:00
Sebastian Bor 3c561381fd
Governance: Create token governance (#1968)
* feat: implement CreateTokenGovernance instruction

* chore: update readme

* chore: add execute transfer instruction test

* chore: update readme

* chore: update comments

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* chore: update readme

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-29 22:22:42 +01:00
Jon Cinque 66d28b41ff
stake-pool: Add helper scripts for setting up a pool (#1994) 2021-06-29 23:11:08 +02:00
dependabot[bot] f2dc9792e6
build(deps): bump @solana/web3.js in /token-swap/js (#1991)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.19.0 to 1.20.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.19.0...v1.20.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 10:16:49 +00:00
dependabot[bot] 0432c19e80
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1990)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.0 to 4.28.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 10:05:12 +00:00
dependabot[bot] f18f4b4275
build(deps): bump @solana/web3.js in /token-lending/js (#1989)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.19.0 to 1.20.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.19.0...v1.20.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 09:53:38 +00:00
dependabot[bot] a4d7d310d3
build(deps): bump @solana/web3.js from 1.19.0 to 1.20.0 in /token/js (#1988)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.19.0 to 1.20.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.19.0...v1.20.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 08:39:30 +00:00
dependabot[bot] 6f1e585a7f
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1987)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.28.0 to 4.28.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 08:13:51 +00:00
Jon Cinque ac2f9e09a4
stake-pool: Fixup accounting on increase transient account (#1985) 2021-06-29 00:51:54 +02:00
dependabot[bot] 0b3552b892
build(deps-dev): bump typescript from 4.3.2 to 4.3.4 in /token/js (#1981)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.2 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.2...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 11:05:47 +00:00
dependabot[bot] 35a78f8990
build(deps-dev): bump eslint from 7.28.0 to 7.29.0 in /token/js (#1980)
Bumps [eslint](https://github.com/eslint/eslint) from 7.28.0 to 7.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.28.0...v7.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 10:52:27 +00:00
dependabot[bot] fcc884c3be
build(deps): bump @solana/web3.js from 1.18.0 to 1.19.0 in /token/js (#1979)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.18.0 to 1.19.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.18.0...v1.19.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 10:41:34 +00:00
dependabot[bot] d82c540e07
build(deps-dev): bump @babel/preset-env in /token/js (#1978)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.14.5 to 7.14.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.7/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 10:28:41 +00:00
dependabot[bot] 200e54df49
build(deps-dev): bump prettier from 2.3.1 to 2.3.2 in /token-swap/js (#1977)
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.3.1...2.3.2)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 10:15:26 +00:00
dependabot[bot] 68d105644c
build(deps-dev): bump prettier from 2.3.1 to 2.3.2 in /token/js (#1976)
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.3.1...2.3.2)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 10:09:48 +00:00
dependabot[bot] 161a36b5ff
build(deps-dev): bump @types/node in /token-lending/js (#1975)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.12.4 to 15.12.5.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 09:56:55 +00:00
dependabot[bot] 37d505f16c
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1974)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 09:53:59 +00:00
dependabot[bot] 2b92107268
build(deps-dev): bump rollup from 2.52.2 to 2.52.3 in /token-lending/js (#1972)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.2 to 2.52.3.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.2...v2.52.3)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 09:45:25 +00:00
dependabot[bot] 49751b6016
build(deps-dev): bump @babel/node from 7.14.5 to 7.14.7 in /token/js (#1971)
Bumps [@babel/node](https://github.com/babel/babel/tree/HEAD/packages/babel-node) from 7.14.5 to 7.14.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.7/packages/babel-node)

---
updated-dependencies:
- dependency-name: "@babel/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 09:40:48 +00:00
dependabot[bot] 4a8da2bb72
build(deps-dev): bump flow-remove-types in /token/js (#1970)
Bumps [flow-remove-types](https://github.com/facebook/flow) from 2.153.0 to 2.154.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/commits)

---
updated-dependencies:
- dependency-name: flow-remove-types
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 08:33:50 +00:00
dependabot[bot] 91eb36f08c
build(deps-dev): bump rollup from 2.52.0 to 2.52.3 in /token/js (#1969)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.0 to 2.52.3.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.0...v2.52.3)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-28 08:13:35 +00:00
Jon Cinque edf07b1f69
stake-pool: Update version for crate publish (#1967)
Finalize the stake pool struct for when a lockup will eventually be
present.
2021-06-25 21:34:48 +00:00
Sebastian Bor 329d7e38ee
Governance: Create mint governance (#1953)
* feat: implement CreateMintGovernance instruction

* fix: ensure mint is initialised in assert_is_valid_spl_token_mint

* fix: ensure token account is initialised in assert_is_valid_spl_token_account

* chore: move account type and instruction to the end to avoid breaking changes

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-25 21:31:14 +01:00
Jon Cinque 683d34d41d
CI: Add status-failure and status-pending check to be sure that all steps are run (#1966)
* Test automerge with `all_github_action_checks` twice

* Add status-failure=0 and status-pending=0 on mergify

* status-pending doesn't exist, use status-neutral
2021-06-25 21:02:24 +02:00
dependabot[bot] 16c2211b47
build(deps-dev): bump flow-bin from 0.152.0 to 0.154.0 in /token-swap/js (#1964)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.152.0 to 0.154.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

---
updated-dependencies:
- dependency-name: flow-bin
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-25 10:14:21 +00:00
dependabot[bot] 3035aa37ae
build(deps-dev): bump @solana/spl-token in /token-swap/js (#1963)
Bumps [@solana/spl-token](https://github.com/solana-labs/solana-program-library) from 0.1.5 to 0.1.6.
- [Release notes](https://github.com/solana-labs/solana-program-library/releases)
- [Commits](https://github.com/solana-labs/solana-program-library/compare/@solana/spl-token@v0.1.5...@solana/spl-token@v0.1.6)

---
updated-dependencies:
- dependency-name: "@solana/spl-token"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-25 09:54:18 +00:00
dependabot[bot] ea2696ecea
build(deps-dev): bump typescript from 4.3.2 to 4.3.4 in /token-swap/js (#1962)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.2 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.2...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-25 09:40:32 +00:00
dependabot[bot] 02b9628598
build(deps): bump @solana/web3.js in /token-swap/js (#1961)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.17.0 to 1.19.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.17.0...v1.19.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-25 09:27:56 +00:00
dependabot[bot] d757aaf759
build(deps): bump @solana/web3.js in /token-lending/js (#1960)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.18.0 to 1.19.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.18.0...v1.19.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-25 09:13:25 +00:00
Jon Cinque 21f8af34e7
Update all solana dependencies to 1.7.3, fix issues (#1958)
* Update all dependencies to 1.7.3, fix issues

* Remove esm from mocha

* Fix missed token test

* Also update rust version

* token-swap: update tolerance on sim test

* Run `cargo clippy --fix` for needless_borrow errors

* Rerun cargo fmt
2021-06-25 00:39:08 +02:00
jordansexton 586e5f9ec5 lending: update fixtures 2021-06-24 17:16:55 -05:00
nope-finance b862c0ec96
Updating toke-lending to use pyth v2 (#1959) 2021-06-24 17:13:56 -05:00
Jon Cinque 6c9ca0d83d
stake-pool: Use `delegation.stake` for accounting (#1934)
* stake-pool: Use `delegation.stake` for accounting

* Clippy

* Improve test and remove spl-math dependency

* Address smaller review comments

* Fix calculation, improve tests

* Clippy

* Remove esm from mocha

* Revert "Remove esm from mocha"

This reverts commit c0f25ab543c808a1daf3474df4ef851bc994fc6c.
2021-06-24 20:30:59 +02:00
jordansexton 4c5f4dffff lending: removed FIXME comments after discussion 2021-06-24 11:25:31 -05:00
dependabot[bot] 1c1ca3ef80
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1955)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-24 08:30:34 +00:00
dependabot[bot] fa4ea78640
build(deps-dev): bump flow-bin from 0.145.0 to 0.154.0 in /token/js (#1954)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.145.0 to 0.154.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

---
updated-dependencies:
- dependency-name: flow-bin
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-24 08:15:06 +00:00
Jordan Sexton ed24c0fe57
lending: fix link anchors 2021-06-23 16:19:48 -05:00
Jordan Sexton 3591f80616
lending: Command Line Interface (#1676) 2021-06-23 16:04:43 -05:00
Lieu Zheng Hong 346075743e
stake-pool: Stake pool deserializer (#1656)
* first commit

* add schema for stakepool accounts

* got imports working

* add typescript support

* fix schema

* Change to use PublicKey type

* change to camelCase instead

* add type annotations to typescript classes

* add readme

* Add prettier linting

* add instructions to run

* add test section

* prettier clean up schema.ts

* convert index.js to index.ts

* actually use decode method available in Assignable

* rename stakepoolaccount so i can have a wrapper class

* add new class StakePool and change return type of getStakePoolAccounts

* remove extraneous .js files

* update schema to incorporate jon's comments

* remove unnecessary comments

* add helper functions to get individual accounts; cleaned up code

* add Fee, change denominator/numerator to BN

* Add enums so we can check what type an accountType is

* Remove name and ticker in StakePool class

* fix borshjs import

* change outdir to dist/ folder

* Edit package.json

* add toBuffer for schema.PublicKey

* add exports and default exports to index.ts

* fix trailing comma on tsconfig.json

* get mocha test harness working with ts-node, ts-mocha, esm

* fix borsh import

* clean up imports

* add working test script

* remove unneeded borshjs import

* add unit tests for both decodes (WIP)

* no need to console.log in testOnDevnet since we now have a test suite

* Add tests for ValidatorListAccount.decode

* add schema.decode.StakePoolAccount test

* Finish up

* reduce dependencies in package.json

* Add lint command to package.json

* Lint with prettier

* Update README.md with new commands

* Write explanatory comments in index.js

* Small linting change

* feat: introduce new borshjs deserializeUnchecked import

* lint: npm lint

* refactor: upgrade web3js version

* refactor: refactor type names

* refactor: npm run lint

* refactor: improve tsconfig.json

* feat: add declaration and declarationMap to tsconfig.json

* feat: allow getStakePoolAccounts to more robustly handle errors

* Update stake-pool/js/.gitignore

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* Update stake-pool/js/package.json

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* Update stake-pool/js/package.json

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* Update stake-pool/js/package.json

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* Update stake-pool/js/package.json

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* refactor: modify `constructStakePoolSchema` to mutate in place

* lint: remove webpack.config.js

* lint: npm run lint

* lint: add comments above index.ts

* lint: lowercase schema

* feat: add full deserialization test

* Update stake-pool/js/package.json

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* refactor: remove try-catch block in getStakePoolAccounts

* lint: lint

* refactor: use web3js pubkey

* refactor: move integration tests to separate file

* refactor: change test.js to do encode-decode loop

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-23 14:18:45 +02:00
dependabot[bot] d10db8df2e
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1952)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-23 09:43:15 +00:00
Jon Cinque 702f1478e8
stake-pool: Split transient stake account creation (#1950) 2021-06-22 21:45:47 +00:00
Jon Cinque de693dc219
stake-pool: Fail initializing if mint has a freeze authority (#1949) 2021-06-22 21:38:08 +00:00
Sebastian Bor 5b34f25b5c
Governance: use runtime program_id (#1947)
* feat: use runtime program_id
* chore: make clippy happy
2021-06-22 22:31:39 +01:00
dependabot[bot] 5702a3a134
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1945)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-22 09:33:35 +00:00
dependabot[bot] 79561cdca3
build(deps-dev): bump @types/node in /token-lending/js (#1944)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.12.2 to 15.12.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-21 10:07:39 +00:00
dependabot[bot] ec69c85e69
build(deps-dev): bump eslint from 7.28.0 to 7.29.0 in /token-lending/js (#1942)
Bumps [eslint](https://github.com/eslint/eslint) from 7.28.0 to 7.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.28.0...v7.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-21 09:54:59 +00:00
dependabot[bot] 6e28f51fd1
build(deps-dev): bump eslint from 7.27.0 to 7.29.0 in /token-swap/js (#1943)
Bumps [eslint](https://github.com/eslint/eslint) from 7.27.0 to 7.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.27.0...v7.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-21 09:54:52 +00:00
dependabot[bot] 37627de5c3
build(deps-dev): bump rollup from 2.52.1 to 2.52.2 in /token-lending/js (#1941)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.1 to 2.52.2.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.1...v2.52.2)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-21 09:32:49 +00:00
dependabot[bot] 86a493c94d
build(deps-dev): bump rollup from 2.52.0 to 2.52.1 in /token-lending/js (#1938)
Bumps [rollup](https://github.com/rollup/rollup) from 2.52.0 to 2.52.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.52.0...v2.52.1)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-18 10:49:02 +00:00
dependabot[bot] 5512882836
build(deps-dev): bump typescript in /token-lending/js (#1937)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-18 10:18:15 +00:00
dependabot[bot] 6d52b4a425
build(deps-dev): bump typescript in /token-lending/js (#1936)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.2 to 4.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.2...v4.3.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-17 09:18:46 +00:00
dependabot[bot] 59440e1d6e
build(deps): bump @solana/web3.js in /token-lending/js (#1932)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.16.1 to 1.18.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.16.1...v1.18.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 11:47:35 +00:00
dependabot[bot] 7aede221ca
build(deps-dev): bump @types/prettier in /token-lending/js (#1931)
Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.2.3 to 2.3.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier)

---
updated-dependencies:
- dependency-name: "@types/prettier"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 11:34:42 +00:00
dependabot[bot] 4d1a9a72a4
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1930)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.26.0 to 4.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.27.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 11:23:09 +00:00
dependabot[bot] 961ae1066e
build(deps): bump @solana/spl-token in /token-lending/js (#1929)
Bumps [@solana/spl-token](https://github.com/solana-labs/solana-program-library) from 0.1.5 to 0.1.6.
- [Release notes](https://github.com/solana-labs/solana-program-library/releases)
- [Commits](https://github.com/solana-labs/solana-program-library/compare/@solana/spl-token@v0.1.5...@solana/spl-token@v0.1.6)

---
updated-dependencies:
- dependency-name: "@solana/spl-token"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 11:11:52 +00:00
dependabot[bot] 56760aaa20
build(deps-dev): bump eslint from 7.27.0 to 7.28.0 in /token-lending/js (#1928)
Bumps [eslint](https://github.com/eslint/eslint) from 7.27.0 to 7.28.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.27.0...v7.28.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 10:52:01 +00:00
dependabot[bot] 52c4c27dfc
build(deps-dev): bump @types/node in /token-lending/js (#1927)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.12.1 to 15.12.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 10:32:09 +00:00
dependabot[bot] fd659c6751
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1926)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.26.0 to 4.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.27.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 10:12:18 +00:00
dependabot[bot] b4d63fd284
build(deps-dev): bump rollup from 2.50.6 to 2.52.0 in /token-lending/js (#1925)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.6 to 2.52.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.6...v2.52.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 09:46:20 +00:00
dependabot[bot] 4b699dac12
build(deps-dev): bump rollup from 2.51.2 to 2.52.0 in /token/js (#1924)
Bumps [rollup](https://github.com/rollup/rollup) from 2.51.2 to 2.52.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.51.2...v2.52.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 09:32:48 +00:00
dependabot[bot] 3bff5580e0
build(deps-dev): bump @babel/core from 7.14.3 to 7.14.6 in /token/js (#1923)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.14.3 to 7.14.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.6/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 08:28:08 +00:00
Jon Cinque a081c2859b
stake-pool: Wait to apply new fee (#1922)
* Add `next_epoch_fee` field and fix serde

* Only update fee after the epoch is passed

* Update docs
2021-06-15 23:40:14 +00:00
jon-chuang 55edf0e9cc
Also clone program data (#1904) 2021-06-15 23:42:43 +02:00
dependabot[bot] f265fb1620
build(deps-dev): bump @babel/preset-env in /token/js (#1921)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.14.4 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 21:10:40 +00:00
dependabot[bot] a92fd2f928
build(deps-dev): bump mocha from 8.4.0 to 9.0.0 in /token/js (#1920)
Bumps [mocha](https://github.com/mochajs/mocha) from 8.4.0 to 9.0.0.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v8.4.0...v9.0.0)

---
updated-dependencies:
- dependency-name: mocha
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 20:49:22 +00:00
dependabot[bot] fbe2cb5b08
build(deps): bump @solana/web3.js from 1.17.0 to 1.18.0 in /token/js (#1919)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.17.0 to 1.18.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.17.0...v1.18.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 20:35:06 +00:00
dependabot[bot] 3cc72d5752
build(deps-dev): bump @babel/plugin-transform-runtime in /token/js (#1918)
Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) from 7.14.3 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-plugin-transform-runtime)

---
updated-dependencies:
- dependency-name: "@babel/plugin-transform-runtime"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 20:18:41 +00:00
dependabot[bot] 9124de9f98
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1917)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.26.0 to 4.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.27.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 19:50:21 +00:00
dependabot[bot] 464cdbdf61
build(deps): bump @babel/runtime from 7.14.0 to 7.14.6 in /token/js (#1915)
Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.14.0 to 7.14.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.6/packages/babel-runtime)

---
updated-dependencies:
- dependency-name: "@babel/runtime"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 19:38:47 +00:00
Tyera Eulberg 02a6854f68
token/js: Bump version to v1.0.6 (#1916) 2021-06-15 13:24:26 -06:00
dependabot[bot] 135d97b1ed
build(deps-dev): bump @babel/cli from 7.14.3 to 7.14.5 in /token/js (#1914)
Bumps [@babel/cli](https://github.com/babel/babel/tree/HEAD/packages/babel-cli) from 7.14.3 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-cli)

---
updated-dependencies:
- dependency-name: "@babel/cli"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 12:24:28 +00:00
dependabot[bot] 83c84270f7
build(deps-dev): bump @babel/plugin-proposal-class-properties (#1913)
Bumps [@babel/plugin-proposal-class-properties](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-proposal-class-properties) from 7.13.0 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-plugin-proposal-class-properties)

---
updated-dependencies:
- dependency-name: "@babel/plugin-proposal-class-properties"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 12:08:58 +00:00
dependabot[bot] f2643ebb1f
build(deps-dev): bump rollup from 2.51.0 to 2.51.2 in /token/js (#1912)
Bumps [rollup](https://github.com/rollup/rollup) from 2.51.0 to 2.51.2.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.51.0...v2.51.2)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 11:54:59 +00:00
dependabot[bot] 8136d9795a
build(deps-dev): bump @babel/preset-flow in /token/js (#1911)
Bumps [@babel/preset-flow](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-flow) from 7.13.13 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-preset-flow)

---
updated-dependencies:
- dependency-name: "@babel/preset-flow"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 11:41:47 +00:00
dependabot[bot] 44f4134ebd
build(deps-dev): bump flow-remove-types in /token/js (#1910)
Bumps [flow-remove-types](https://github.com/facebook/flow) from 2.152.0 to 2.153.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/commits)

---
updated-dependencies:
- dependency-name: flow-remove-types
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 10:24:57 +00:00
dependabot[bot] 09239bbf71
build(deps-dev): bump @babel/node from 7.14.2 to 7.14.5 in /token/js (#1909)
Bumps [@babel/node](https://github.com/babel/babel/tree/HEAD/packages/babel-node) from 7.14.2 to 7.14.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.5/packages/babel-node)

---
updated-dependencies:
- dependency-name: "@babel/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 09:23:40 +00:00
dependabot[bot] db4792c4fe
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1908)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.26.0 to 4.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.27.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-15 08:22:39 +00:00
Tyera Eulberg c2f3ed530e Bump spl-token-cli 2021-06-14 16:02:27 -06:00
Tyera Eulberg e28af24443 Bump solana version 2021-06-14 16:02:27 -06:00
dependabot[bot] fe6447e9a7
build(deps): bump glob-parent from 5.1.1 to 5.1.2 in /token-lending/js (#1903)
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-12 09:03:41 +00:00
Jon Cinque ddf9efa330
stake-pool: Add ability to withdraw from transient stakes (#1890)
* stake-pool: Add ability to withdraw from transient stakes

It's possible for a very malicious pool staker to constantly increase /
decrease the stake on validators, making it impossible for people to get
their SOL out.

Update the accounting to know how much of the stake is active and how
much is transient and allow users to withdraw from transient accounts,
but only if there's no more active stake.

* Remove mut ickiness
2021-06-11 20:50:59 +00:00
Jon Cinque de8433e815
ci: Split out test-bpf into separate workflows for each program (#1893)
* ci: Split token, token-swap, and token-lending out

* Remove token lending js in main runner

* token-swap: Update proptest to trigger build

* Remove unused Cargo.lock file

* lending: Update proptest to trigger lending build

* Fix lending test

* Try re-using action

* binary-oracle-pair: Bump token version to trigger build

* Reference action differently

* Add checkout step before local action

* Move out cargo test bpf step

* Add more programs

* Update example file to trigger job

* Update library file to trigger build

* Update name-service file to trigger build

* Update record file to trigger build

* Update shared memory file to trigger build

* Add pull request runners for each probram / library

* Fix pull-request yml file referencing unknown step
2021-06-11 22:35:00 +02:00
Jordan Sexton e2d018526f
lending: minor doc comment / match order fixes (#1899)
* fix docs

* make instruction order consistent
2021-06-10 22:55:25 -05:00
Justin Starry e25b687d2f
Add community label to external contributions (#1898) 2021-06-10 17:45:54 -07:00
Tyera Eulberg f519dc7549
Fixup spl-token create-account example (#1897) 2021-06-10 19:13:07 +00:00
Justin Starry 3cf9f0d0f9
spl-token-cli: Remove global owner argument (#1870) 2021-06-10 11:52:39 -07:00
Tyera Eulberg 34af3726fd
Update some api urls (#1888) 2021-06-08 12:53:32 -06:00
Tyera Eulberg e20cfbee44
Update api urls in docs (#1887) 2021-06-08 12:24:49 -06:00
Jordan Sexton 4ffc2f6e05
lending: use Pyth as oracle (#1757) 2021-06-07 18:52:26 -05:00
dependabot[bot] e313f972bd
build(deps-dev): bump eslint from 7.27.0 to 7.28.0 in /token/js (#1882)
Bumps [eslint](https://github.com/eslint/eslint) from 7.27.0 to 7.28.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.27.0...v7.28.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 12:31:05 +00:00
dependabot[bot] 506a1b88d5
build(deps): bump @solana/web3.js from 1.16.1 to 1.17.0 in /token/js (#1881)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.16.1 to 1.17.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.16.1...v1.17.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 11:49:14 +00:00
dependabot[bot] b14c0f7447
build(deps-dev): bump prettier from 2.3.0 to 2.3.1 in /token/js (#1879)
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.0 to 2.3.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.3.0...2.3.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 11:12:28 +00:00
dependabot[bot] 462a4834a6
build(deps-dev): bump start-server-and-test in /token-swap/js (#1878)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.4 to 1.12.5.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.4...v1.12.5)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 11:04:14 +00:00
dependabot[bot] ddc8f952ba
build(deps-dev): bump prettier from 2.3.0 to 2.3.1 in /token-swap/js (#1877)
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.0 to 2.3.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.3.0...2.3.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 10:38:59 +00:00
dependabot[bot] 52054b254b
build(deps-dev): bump start-server-and-test in /token-lending/js (#1876)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.3 to 1.12.5.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.3...v1.12.5)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 10:25:58 +00:00
dependabot[bot] 98b0a37b8e
build(deps-dev): bump rollup from 2.50.6 to 2.51.0 in /token/js (#1875)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.6 to 2.51.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.6...v2.51.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 10:24:59 +00:00
dependabot[bot] 07b4a56752
build(deps-dev): bump @types/node in /token-lending/js (#1874)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.9.0 to 15.12.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 09:46:27 +00:00
dependabot[bot] ed9fbf0f9d
build(deps-dev): bump start-server-and-test in /token/js (#1872)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.4 to 1.12.5.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.4...v1.12.5)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-07 09:20:13 +00:00
Sebastian Bor c9e3689a94
Governance: Instructions (#1833)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-05 14:06:57 +01:00
Jon Cinque 329f9c0912
stake-pool: Add explicit ownership checks (#1868) 2021-06-04 21:45:49 +00:00
Jon Cinque ba99e44bff
stake-pool: Add reserve stake check on update pool balance (#1866) 2021-06-04 23:08:32 +02:00
Jon Cinque 454c75c711
stake-pool: Document writability of validator list (#1867) 2021-06-04 22:15:39 +02:00
dependabot[bot] 8919174aab
build(deps): bump @solana/web3.js in /token-swap/js (#1860)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.16.1 to 1.17.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.16.1...v1.17.0)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-04 10:42:57 +00:00
dependabot[bot] 75a96d8c01
build(deps-dev): bump start-server-and-test in /token-swap/js (#1859)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.3 to 1.12.4.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.3...v1.12.4)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-04 10:35:58 +00:00
dependabot[bot] 4e2d195944
build(deps-dev): bump start-server-and-test in /token/js (#1857)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.3 to 1.12.4.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.3...v1.12.4)

---
updated-dependencies:
- dependency-name: start-server-and-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-04 08:40:49 +00:00
Jon Cinque 9d7dae8bb4
token-docs: add token registry (#1855)
* token-docs: add token registry

* Update docs/src/token.md

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2021-06-03 22:55:09 +02:00
dependabot[bot] 95a3013d55
build(deps): bump @solana/web3.js in /token-lending/js (#1854)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.15.0 to 1.16.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.15.0...v1.16.1)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 11:17:02 +00:00
Henry-E ef9684db04
Comment says javascript but code is typescript (#1744)
* Comment says javascript but code is typescript

* Update docs/src/associated-token-account.md

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-03 13:13:55 +02:00
dependabot[bot] 09cf39ed98
build(deps-dev): bump rollup from 2.50.5 to 2.50.6 in /token-lending/js (#1853)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.5 to 2.50.6.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.5...v2.50.6)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 10:41:37 +00:00
dependabot[bot] 55b3c60105
build(deps): bump @solana/web3.js in /token-swap/js (#1852)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.15.0 to 1.16.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.15.0...v1.16.1)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 10:39:31 +00:00
dependabot[bot] ed75b8abf6
build(deps-dev): bump @types/node in /token-lending/js (#1851)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.6.2 to 15.9.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 10:03:22 +00:00
dependabot[bot] b0a43c2bab
build(deps): bump @solana/web3.js from 1.15.0 to 1.16.1 in /token/js (#1850)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.15.0 to 1.16.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.15.0...v1.16.1)

---
updated-dependencies:
- dependency-name: "@solana/web3.js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 09:58:12 +00:00
dependabot[bot] b53bcdacc4
build(deps-dev): bump rollup from 2.50.5 to 2.50.6 in /token/js (#1849)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.5 to 2.50.6.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.5...v2.50.6)

---
updated-dependencies:
- dependency-name: rollup
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-03 08:36:51 +00:00
dependabot[bot] a2e5ce0e0f
build(deps-dev): bump @types/eslint in /token-lending/js (#1847)
Bumps [@types/eslint](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/eslint) from 7.2.12 to 7.2.13.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/eslint)

---
updated-dependencies:
- dependency-name: "@types/eslint"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-02 10:37:50 +00:00
dependabot[bot] 577291b1a5
build(deps-dev): bump @types/node in /token-lending/js (#1846)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.6.1 to 15.6.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-02 10:04:05 +00:00
Jordan Sexton 58e78ca85c
lending: Flash Loan fixes (#1803)
* reorganize accounts expected, rename for consistency

* persist reserve state before and after CPI

* add doc comment

* add fixme comment

* add test for flash loan fee calc

* reorg and fix tests

* cargo fmt

* check that token program matches market's

* rearrange a few lines

* increase compute budget for test on CI

* add fixme and check for reentrancy
2021-06-01 18:56:34 -05:00
Yihau Chen 6dada44f75 fix lint 2021-06-01 11:03:03 -06:00
Yihau Chen f5fb183b2d add allowOwnerOffCurve flag in getAssociatedTokenAddress 2021-06-01 11:03:03 -06:00
dependabot[bot] 9d5ee88707
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1843)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.25.0 to 4.26.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.26.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-01 11:46:39 +00:00
dependabot[bot] 5c2e4e8ca5
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1842)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.25.0 to 4.26.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.26.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-01 11:10:17 +00:00
Jon Cinque 450b2d511a
stake-pool: Add preferred deposit / withdraw validator accounts (#1831)
* stake-pool: Add set preferred validator instruction

* Add functionality for using the preferred deposit / withdraw

* Add CLI support
2021-06-01 12:45:27 +02:00
dependabot[bot] e5c0d64c50
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1841)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.25.0 to 4.26.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.26.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-01 10:31:55 +00:00
dependabot[bot] cb7f81cd69
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1840)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.25.0 to 4.26.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.26.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-01 09:50:22 +00:00
dependabot[bot] eb5354d129
build(deps-dev): bump rollup from 2.50.3 to 2.50.5 in /token/js (#1839)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.3 to 2.50.5.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.3...v2.50.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-01 08:41:04 +00:00
dependabot[bot] 3e5bb7cada
build(deps-dev): bump eslint-plugin-import in /token-swap/js (#1837)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.23.3 to 2.23.4.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.23.3...v2.23.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-31 10:38:40 +00:00
dependabot[bot] 921348709a
build(deps-dev): bump eslint-plugin-import in /token/js (#1836)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.23.3 to 2.23.4.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.23.3...v2.23.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-31 09:57:04 +00:00
dependabot[bot] 8369803041
build(deps-dev): bump rollup from 2.50.3 to 2.50.5 in /token-lending/js (#1835)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.3 to 2.50.5.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.3...v2.50.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-31 09:41:15 +00:00
dependabot[bot] 051e201cae
build(deps-dev): bump @babel/preset-env in /token/js (#1834)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.14.2 to 7.14.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.4/packages/babel-preset-env)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-31 09:17:47 +00:00
Sebastian Bor f59e43757b
Governance: Voting workflow
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-29 22:51:48 +01:00
Max Block b8c2968cd1 fix a 404 link 2021-05-28 23:42:25 -07:00
dependabot[bot] a3dbf08998
build(deps-dev): bump ts-node from 9.1.1 to 10.0.0 in /token-lending/js (#1830)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 9.1.1 to 10.0.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v9.1.1...v10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 12:12:56 +00:00
dependabot[bot] 0c83fdae66
build(deps-dev): bump rollup from 2.50.2 to 2.50.3 in /token/js (#1829)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.2 to 2.50.3.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.2...v2.50.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 11:34:26 +00:00
dependabot[bot] 7c605652a2
build(deps): bump @solana/web3.js in /token-lending/js (#1828)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.13.0 to 1.15.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.13.0...v1.15.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 11:34:21 +00:00
dependabot[bot] b2bf8a0753
build(deps-dev): bump typescript from 4.2.4 to 4.3.2 in /token/js (#1823)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.4 to 4.3.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.4...v4.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 11:00:37 +00:00
dependabot[bot] 4c97074feb
build(deps-dev): bump rollup from 2.48.0 to 2.50.3 in /token-lending/js (#1827)
Bumps [rollup](https://github.com/rollup/rollup) from 2.48.0 to 2.50.3.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.48.0...v2.50.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 10:59:07 +00:00
dependabot[bot] 25a76217a7
build(deps-dev): bump @solana/spl-token in /token-swap/js (#1825)
Bumps [@solana/spl-token](https://github.com/solana-labs/solana-program-library) from 0.1.4 to 0.1.5.
- [Release notes](https://github.com/solana-labs/solana-program-library/releases)
- [Commits](https://github.com/solana-labs/solana-program-library/compare/@solana/spl-token@v0.1.4...@solana/spl-token@v0.1.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 10:35:34 +00:00
dependabot[bot] 82578a22f4
build(deps): bump @solana/web3.js in /token-swap/js (#1826)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.14.0...v1.15.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 10:35:30 +00:00
dependabot[bot] 4adfcaafdf
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1824)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.24.0 to 4.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.25.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 10:22:23 +00:00
Jon Cinque b310c2a163
stake-pool: Add program_id to all instruction ctors (#1814) 2021-05-28 11:46:57 +02:00
dependabot[bot] 1dcab7b605
build(deps-dev): bump @types/node in /token-lending/js (#1822)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.3.0 to 15.6.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 09:44:57 +00:00
dependabot[bot] 7eb621d769
build(deps-dev): bump flow-remove-types in /token/js (#1821)
Bumps [flow-remove-types](https://github.com/facebook/flow) from 2.151.0 to 2.152.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 09:43:56 +00:00
dependabot[bot] 7df63a831d
build(deps-dev): bump eslint from 7.26.0 to 7.27.0 in /token-lending/js (#1820)
Bumps [eslint](https://github.com/eslint/eslint) from 7.26.0 to 7.27.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.26.0...v7.27.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 08:45:57 +00:00
dependabot[bot] 75e772792c
build(deps-dev): bump rollup from 2.50.1 to 2.50.2 in /token/js (#1819)
Bumps [rollup](https://github.com/rollup/rollup) from 2.50.1 to 2.50.2.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.50.1...v2.50.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 08:41:59 +00:00
dependabot[bot] 2621217f2e
build(deps): bump @solana/spl-token in /token-lending/js (#1817)
Bumps [@solana/spl-token](https://github.com/solana-labs/solana-program-library) from 0.1.4 to 0.1.5.
- [Release notes](https://github.com/solana-labs/solana-program-library/releases)
- [Commits](https://github.com/solana-labs/solana-program-library/compare/@solana/spl-token@v0.1.4...@solana/spl-token@v0.1.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 08:06:52 +00:00
dependabot[bot] 3af3414481
build(deps-dev): bump eslint-plugin-mocha in /token/js (#1818)
Bumps [eslint-plugin-mocha](https://github.com/lo1tuma/eslint-plugin-mocha) from 8.1.0 to 9.0.0.
- [Release notes](https://github.com/lo1tuma/eslint-plugin-mocha/releases)
- [Changelog](https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lo1tuma/eslint-plugin-mocha/compare/8.1.0...9.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 08:01:58 +00:00
dependabot[bot] a421eb7029
build(deps): bump @solana/web3.js from 1.13.0 to 1.15.0 in /token/js (#1816)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.13.0 to 1.15.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.13.0...v1.15.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 07:27:14 +00:00
dependabot[bot] 35069f6ffb
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1813)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.24.0 to 4.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.25.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 07:26:11 +00:00
Trent Nelson da2c3d00ae token/js: Bump version to v1.0.5 2021-05-28 05:51:16 +00:00
dependabot[bot] 9df31b10c0
build(deps-dev): bump dotenv from 9.0.2 to 10.0.0 in /token-lending/js (#1812)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 9.0.2 to 10.0.0.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v9.0.2...v10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-27 12:36:37 +00:00
dependabot[bot] 42ad8b2ad4
build(deps-dev): bump typescript in /token-lending/js (#1810)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.4 to 4.3.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.4...v4.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-27 11:59:22 +00:00
dependabot[bot] 57cf2c20fa
build(deps-dev): bump typescript from 4.2.4 to 4.3.2 in /token-swap/js (#1809)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.4 to 4.3.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.4...v4.3.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-27 11:22:17 +00:00
dependabot[bot] 09b8be5071
build(deps-dev): bump flow-bin from 0.151.0 to 0.152.0 in /token-swap/js (#1808)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.151.0 to 0.152.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-27 11:21:12 +00:00
dependabot[bot] 1188d906ea
build(deps-dev): bump @types/eslint in /token-lending/js (#1807)
Bumps [@types/eslint](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/eslint) from 7.2.10 to 7.2.12.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/eslint)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-27 11:08:39 +00:00
Sebastian Bor 94350d0e8e
Governance: Create Proposals and Sign Off workflow (#1767)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-26 16:40:18 +01:00
dependabot[bot] ecc25f7d26
build(deps): bump @solana/web3.js in /token-swap/js (#1800)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.13.0 to 1.14.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.13.0...v1.14.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-26 10:33:40 +00:00
dependabot[bot] c3657e5568
build(deps-dev): bump rollup from 2.49.0 to 2.50.1 in /token/js (#1798)
Bumps [rollup](https://github.com/rollup/rollup) from 2.49.0 to 2.50.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.49.0...v2.50.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-26 08:38:19 +00:00
Jack May 813aa33040
Update sysvar example (#1795) 2021-05-25 16:58:36 -07:00
Jon Cinque 929dd59e50
token-swap: Fuzz all curves (#1796) 2021-05-25 22:10:31 +00:00
Jon Cinque 5f692a0b61
token-swap: Make single token withdrawal fair with better calcs (#1794)
* Separate deposit and withdraw single side calcs

* token-swap: Make single token withdrawal fair with better calcs

* Fix JS test calcs
2021-05-25 22:05:06 +02:00
Sebastian Bor 6b3fbb8ff5
chore: update solana to 1.6.7 and rust to 1.52.1 (#1792) 2021-05-25 13:57:45 +01:00
dependabot[bot] c548e32119
build(deps-dev): bump start-server-and-test in /token-swap/js (#1790)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.2 to 1.12.3.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.2...v1.12.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 10:42:48 +00:00
dependabot[bot] d31bec8339
build(deps): bump @solana/web3.js in /token-swap/js (#1791)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.12.0...v1.13.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 10:38:43 +00:00
dependabot[bot] 3fe5291570
build(deps-dev): bump start-server-and-test in /token-lending/js (#1788)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.2 to 1.12.3.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.2...v1.12.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 10:00:27 +00:00
dependabot[bot] 9837c62a42
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1787)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.24.0 to 4.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.25.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 09:55:59 +00:00
dependabot[bot] 44c12ff8ab
build(deps): bump @solana/web3.js in /token-lending/js (#1786)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.11.0 to 1.13.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.11.0...v1.13.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 09:22:18 +00:00
dependabot[bot] 5b6439fca8
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1785)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.24.0 to 4.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.25.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 09:20:44 +00:00
dependabot[bot] b0591808ec
build(deps): bump @solana/web3.js from 1.12.0 to 1.13.0 in /token/js (#1784)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.12.0...v1.13.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 08:44:22 +00:00
dependabot[bot] 9a857654c7
build(deps-dev): bump start-server-and-test in /token/js (#1783)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.1 to 1.12.3.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.1...v1.12.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 15:12:24 +00:00
dependabot[bot] 73c3ea2bd5
build(deps): bump dotenv from 9.0.2 to 10.0.0 in /token/js (#1782)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 9.0.2 to 10.0.0.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v9.0.2...v10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 14:29:18 +00:00
dependabot[bot] 7992d85530
build(deps-dev): bump rollup from 2.47.0 to 2.49.0 in /token/js (#1781)
Bumps [rollup](https://github.com/rollup/rollup) from 2.47.0 to 2.49.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.47.0...v2.49.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 13:47:50 +00:00
dependabot[bot] 8a9202c204
build(deps-dev): bump @babel/core from 7.14.2 to 7.14.3 in /token/js (#1780)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.14.2 to 7.14.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.3/packages/babel-core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 13:05:54 +00:00
dependabot[bot] 40dec6e1fe
build(deps-dev): bump eslint from 7.26.0 to 7.27.0 in /token/js (#1779)
Bumps [eslint](https://github.com/eslint/eslint) from 7.26.0 to 7.27.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.26.0...v7.27.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 12:21:38 +00:00
dependabot[bot] 696abe1844
build(deps-dev): bump eslint from 7.26.0 to 7.27.0 in /token-swap/js (#1776)
Bumps [eslint](https://github.com/eslint/eslint) from 7.26.0 to 7.27.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.26.0...v7.27.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 12:21:34 +00:00
dependabot[bot] 98aa6000dc
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1777)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.23.0 to 4.24.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.24.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 11:45:42 +00:00
dependabot[bot] c6cd23fa2e
build(deps): bump dotenv from 9.0.2 to 10.0.0 in /token-swap/js (#1778)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 9.0.2 to 10.0.0.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v9.0.2...v10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 11:44:28 +00:00
dependabot[bot] 3377a0d39d
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1775)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.23.0 to 4.24.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.24.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 11:12:23 +00:00
dependabot[bot] 50665fd549
build(deps-dev): bump eslint-plugin-import in /token-swap/js (#1774)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.23.2 to 2.23.3.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.23.2...v2.23.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 11:12:17 +00:00
dependabot[bot] 62c59b0453
build(deps-dev): bump ts-node from 9.1.1 to 10.0.0 in /token-swap/js (#1773)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 9.1.1 to 10.0.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v9.1.1...v10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 11:08:30 +00:00
dependabot[bot] 69ec863802
build(deps-dev): bump @babel/cli from 7.13.16 to 7.14.3 in /token/js (#1772)
Bumps [@babel/cli](https://github.com/babel/babel/tree/HEAD/packages/babel-cli) from 7.13.16 to 7.14.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.3/packages/babel-cli)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 10:08:20 +00:00
dependabot[bot] 7b150f841a
build(deps-dev): bump @babel/plugin-transform-runtime in /token/js (#1771)
Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) from 7.14.2 to 7.14.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.3/packages/babel-plugin-transform-runtime)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 09:31:11 +00:00
dependabot[bot] bf0fd7aaa0
build(deps-dev): bump eslint-plugin-import in /token/js (#1770)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.22.1 to 2.23.3.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.22.1...v2.23.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-24 08:55:11 +00:00
Sebastian Bor b488aee067
Governance: Create governance accounts
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-23 00:36:02 +01:00
Michael Vines ed0389f708 Add forward compatibility with solana-client 1.6.10 2021-05-22 00:00:33 -07:00
Trent Nelson d4dd97b3b1 fix: token/js bump web3.js to 1.12.0 2021-05-21 00:53:46 +00:00
Jon Cinque ea98e6bf73
stake-pool: Fix fee calculation (#1764)
* stake-pool: Fix fee calculation

* Remove unwraps, widen one more calc
2021-05-20 11:53:06 +00:00
Sebastian Bor addc6bf4b4
Governance: Implement Realms
Implemented instructions:
- CreateRealm
- DepositGoverningTokens
- WithdrawGoverningTokens
-SetVoteAuthority

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2021-05-19 12:20:53 +01:00
dependabot[bot] 79f31e320f
build(deps): bump @solana/web3.js in /token-swap/js (#1762)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.11.0...v1.12.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-19 10:38:04 +00:00
akamutsu 4915c0910a
Implementation of stable curve methods (#1488)
* WIP: Implementation of the remainder of stablecurve methods

* Edits based on PR feedback

* revert SwapVersion

* PR fixes

* checked add / sub

* reverted to using RoundDirection instead of LiquidityProviderOperaiton

* removed LiquidityProviderOperation enum

* Revert flipped parameters

* initial attempt at noramlized_value

* use d for noramlize value for stable curve

* TradeDirection instead of RoundDirection for trading_tokens_to_pool_tokens

* reimplemented the trading_tokens_to_pool tokens function for stable

* Typo

* fix rounding errors in pool_tokens_to_trading_tokens

* try different values of amplification factor in test for stable curve

* fixed broken tests, use constant_product normalized_value function

* use cubic solver

* fix noramlize_value function bad maths

* redid noramlized value for one last time

* added more proptests

* Get tests to work

* Fixup for prod usage

Co-authored-by: Yutaro Mori <me@yutaromori.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-19 02:44:01 +02:00
dependabot[bot] 3426b714aa
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1759)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.23.0 to 4.24.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.24.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-18 21:22:01 +00:00
B 06630018c2
Name Service JavaScript cleanup (#1755)
* fix: update id + lint + spelling

* feat: add twitter const

* chore: update to Keypair

* fix: exports + lint

* feat: add twitter instructions

* chore: add readme
2021-05-18 15:45:30 -05:00
Jonathan LEI 26560daae2
Fix #1739: ThawAccount incorrectly logged as FreezeAccount in token program (#1740) 2021-05-18 18:32:12 +02:00
dependabot[bot] 8555f2d222
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1758)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.23.0 to 4.24.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.24.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-18 09:40:33 +00:00
Michael Vines b1629a18f6 Bump spl-token patch version 2021-05-17 20:26:25 -07:00
Jordan Sexton cef8b7363f
lending: fix bad account in instruction docs 2021-05-17 17:24:10 -05:00
Michael Vines 5afe5c7175 Remove unneeded helper function 2021-05-17 13:07:23 -07:00
dependabot[bot] 0eadd43890
build(deps): bump @solana/web3.js in /token-lending/js (#1753)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.10.1 to 1.11.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.10.1...v1.11.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 11:53:12 +00:00
dependabot[bot] e8c97e3cb2
build(deps-dev): bump start-server-and-test in /token-swap/js (#1752)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.1 to 1.12.2.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.1...v1.12.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 11:18:28 +00:00
dependabot[bot] d8c062e522
build(deps-dev): bump @types/node in /token-lending/js (#1751)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.0.3 to 15.3.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 11:17:40 +00:00
Sebastian Bor e5af52d6e7
Governance program API design
Co-authored-by: Michael Vines <mvines@gmail.com>
2021-05-17 12:01:20 +01:00
dependabot[bot] 1beeb9fd21
build(deps-dev): bump eslint-plugin-import in /token-swap/js (#1749)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.23.0 to 2.23.2.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.23.0...v2.23.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 10:42:08 +00:00
dependabot[bot] 9da22609af
build(deps): bump @solana/web3.js in /token-swap/js (#1750)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.10.1 to 1.11.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.10.1...v1.11.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 10:41:13 +00:00
dependabot[bot] 9342fa39f3
build(deps-dev): bump rollup from 2.47.0 to 2.48.0 in /token-lending/js (#1748)
Bumps [rollup](https://github.com/rollup/rollup) from 2.47.0 to 2.48.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.47.0...v2.48.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 10:19:30 +00:00
dependabot[bot] df466175ae
build(deps-dev): bump start-server-and-test in /token-lending/js (#1747)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.1 to 1.12.2.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.1...v1.12.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-17 09:41:24 +00:00
dependabot[bot] 6b82600d05
build(deps-dev): bump eslint-plugin-import in /token-swap/js (#1741)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.22.1 to 2.23.0.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.22.1...v2.23.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-14 10:35:28 +00:00
dependabot[bot] 0f9859410f
build(deps-dev): bump @babel/preset-flow in /token/js (#1735)
Bumps [@babel/preset-flow](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-flow) from 7.12.13 to 7.13.13.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.13/packages/babel-preset-flow)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 19:55:03 +00:00
dependabot[bot] c71671cf2a
build(deps-dev): bump prettier from 2.2.1 to 2.3.0 in /token/js (#1734)
Bumps [prettier](https://github.com/prettier/prettier) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.2.1...2.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 19:15:11 +00:00
dependabot[bot] a1071cd8c6
build(deps-dev): bump flow-remove-types in /token/js (#1733)
Bumps [flow-remove-types](https://github.com/facebook/flow) from 2.146.0 to 2.151.0.
- [Release notes](https://github.com/facebook/flow/releases)
- [Changelog](https://github.com/facebook/flow/blob/master/Changelog.md)
- [Commits](https://github.com/facebook/flow/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 18:32:51 +00:00
dependabot[bot] 7b897cf0de
build(deps-dev): bump start-server-and-test in /token/js (#1732)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.0...v1.12.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 17:57:42 +00:00
dependabot[bot] dc730085de
build(deps-dev): bump @typescript-eslint/parser in /token/js (#1731)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.17.0 to 4.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.23.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 17:22:46 +00:00
dependabot[bot] 5e58890397
build(deps-dev): bump mocha from 8.3.2 to 8.4.0 in /token/js (#1730)
Bumps [mocha](https://github.com/mochajs/mocha) from 8.3.2 to 8.4.0.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v8.3.2...v8.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 16:44:45 +00:00
dependabot[bot] 6903f32221
build(deps): bump buffer-layout from 1.2.0 to 1.2.1 in /token/js (#1729)
Bumps [buffer-layout](https://github.com/pabigot/buffer-layout) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/pabigot/buffer-layout/releases)
- [Changelog](https://github.com/pabigot/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pabigot/buffer-layout/commits/v1.2.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 16:10:39 +00:00
dependabot[bot] 893ab9f2f5
build(deps): bump dotenv from 8.2.0 to 9.0.2 in /token/js (#1728)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 8.2.0 to 9.0.2.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v8.2.0...v9.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 15:34:36 +00:00
dependabot[bot] f2d4ad4500
build(deps-dev): bump typescript from 4.2.3 to 4.2.4 in /token/js (#1727)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.3 to 4.2.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.3...v4.2.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 14:57:23 +00:00
dependabot[bot] ba389f9581
build(deps-dev): bump @rollup/plugin-commonjs in /token/js (#1726)
Bumps [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/HEAD/packages/commonjs) from 17.1.0 to 19.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Changelog](https://github.com/rollup/plugins/blob/master/packages/commonjs/CHANGELOG.md)
- [Commits](https://github.com/rollup/plugins/commits/commonjs-v19.0.0/packages/commonjs)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 14:21:30 +00:00
dependabot[bot] 2625fb006b
build(deps-dev): bump eslint-plugin-flowtype in /token/js (#1725)
Bumps [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype) from 5.6.0 to 5.7.2.
- [Release notes](https://github.com/gajus/eslint-plugin-flowtype/releases)
- [Commits](https://github.com/gajus/eslint-plugin-flowtype/compare/v5.6.0...v5.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 13:48:22 +00:00
dependabot[bot] ee4a135e20
build(deps-dev): bump @babel/plugin-transform-runtime in /token/js (#1724)
Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) from 7.13.10 to 7.14.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.2/packages/babel-plugin-transform-runtime)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 13:13:46 +00:00
dependabot[bot] c0af8bdd0a
build(deps-dev): bump eslint from 7.21.0 to 7.26.0 in /token/js (#1723)
Bumps [eslint](https://github.com/eslint/eslint) from 7.21.0 to 7.26.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.21.0...v7.26.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 12:39:21 +00:00
dependabot[bot] 7fe1abeb6b
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1722)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.22.1 to 4.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.23.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 12:03:25 +00:00
dependabot[bot] 59c6bb7072
build(deps-dev): bump @babel/node from 7.13.10 to 7.14.2 in /token/js (#1721)
Bumps [@babel/node](https://github.com/babel/babel/tree/HEAD/packages/babel-node) from 7.13.10 to 7.14.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.2/packages/babel-node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 11:26:27 +00:00
dependabot[bot] 561053730e
build(deps-dev): bump @babel/core from 7.13.10 to 7.14.2 in /token/js (#1720)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.13.10 to 7.14.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.2/packages/babel-core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:51:15 +00:00
dependabot[bot] 56572e32cb
build(deps-dev): bump flow-bin from 0.142.0 to 0.151.0 in /token-swap/js (#1719)
Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.142.0 to 0.151.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:37:55 +00:00
dependabot[bot] 2492734068
build(deps): bump @solana/web3.js from 1.9.1 to 1.10.1 in /token/js (#1717)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.9.1 to 1.10.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.9.1...v1.10.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 10:17:07 +00:00
dependabot[bot] 0f82fa7d9c
build(deps-dev): bump @types/node in /token-lending/js (#1718)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.0.2 to 15.0.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 09:39:00 +00:00
dependabot[bot] 1a6df09e89
build(deps-dev): bump @babel/preset-env in /token/js (#1716)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.13.10 to 7.14.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.2/packages/babel-preset-env)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-13 08:44:36 +00:00
Elliott Benisty 58221fc9ae
Fix potential vulnerabilities in programs using spl-token CPIs by adding program id checks (#1714)
* Add spl-token program id check helper function. Add program id to instruction bindings.

* Run cargo fmt

* Fixup tests

* Skip ATA tests when custom token program-id

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2021-05-12 22:36:41 +00:00
Jon Cinque d4bbdf8224
stake-pool-cli: Bump version for release (#1713)
* stake-pool-cli: Bump version for release

* Update lock file
2021-05-12 13:20:48 +00:00
drbh 41568014eb implement the ability to leave a memo on token creation 2021-05-11 20:21:08 -07:00
Jon Cinque 731bb6f57a
stake-pool: Bump version for release (#1707) 2021-05-11 21:46:49 +00:00
Jon Cinque cebb3176b2
stake-pool: Add helper instruction creators for stake pool integration (#1706)
* stake-pool: Add more instructions for easier usage

* Add extra check (shouldn't be necessary, but who knows?)
2021-05-11 20:48:58 +00:00
drbh f3a8fae2f5
swap associated token account addr for token addr (#1705)
the associated token account address is derived from token address. The token address is the correct argument.
2021-05-11 13:45:15 -06:00
dependabot[bot] 3709ac60db
build(deps-dev): bump prettier from 2.2.1 to 2.3.0 in /token-swap/js (#1703)
Bumps [prettier](https://github.com/prettier/prettier) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.2.1...2.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 14:05:42 +00:00
dependabot[bot] 5a9eebd692
build(deps): bump @solana/web3.js in /token-swap/js (#1702)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.10.0...v1.10.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 13:30:21 +00:00
dependabot[bot] d3d527e26b
build(deps): bump dotenv from 8.2.0 to 9.0.2 in /token-swap/js (#1701)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 8.2.0 to 9.0.2.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v8.2.0...v9.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 12:57:47 +00:00
dependabot[bot] 88eb28625b
build(deps-dev): bump start-server-and-test in /token-swap/js (#1700)
Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/bahmutov/start-server-and-test/releases)
- [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.12.0...v1.12.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 12:25:58 +00:00
dependabot[bot] e7360196ae
build(deps): bump @solana/web3.js in /token-lending/js (#1699)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.10.0...v1.10.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 11:48:30 +00:00
dependabot[bot] 0007114121
build(deps-dev): bump eslint from 7.21.0 to 7.26.0 in /token-swap/js (#1698)
Bumps [eslint](https://github.com/eslint/eslint) from 7.21.0 to 7.26.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.21.0...v7.26.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 11:47:39 +00:00
dependabot[bot] 848c580889
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1695)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.22.1 to 4.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.23.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 11:08:29 +00:00
dependabot[bot] 7f3ccec305
build(deps): bump buffer-layout from 1.2.0 to 1.2.1 in /token-swap/js (#1696)
Bumps [buffer-layout](https://github.com/pabigot/buffer-layout) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/pabigot/buffer-layout/releases)
- [Changelog](https://github.com/pabigot/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pabigot/buffer-layout/commits/v1.2.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 10:34:31 +00:00
dr497 1f48b5bc5e docs: add token vesting section 2021-05-10 20:11:23 -07:00
dependabot[bot] 8a02ab5650
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1694)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.22.1 to 4.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.23.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 22:58:19 +00:00
dependabot[bot] 7336a7641e
build(deps-dev): bump dotenv from 9.0.1 to 9.0.2 in /token-lending/js (#1693)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 9.0.1 to 9.0.2.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v9.0.1...v9.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 22:21:06 +00:00
dependabot[bot] e402aed8dd
build(deps): bump @solana/web3.js in /token-lending/js (#1692)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.9.1...v1.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 21:45:45 +00:00
dependabot[bot] 96100f751b
build(deps-dev): bump eslint from 7.25.0 to 7.26.0 in /token-lending/js (#1691)
Bumps [eslint](https://github.com/eslint/eslint) from 7.25.0 to 7.26.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.25.0...v7.26.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 21:07:59 +00:00
Pierre 6ac82f9caf
token-swap typescript: Move things around, fix typing problems (#1643)
* Move things around, fix typing problems

* oups output built in src

* fix typegen

* fix cli

* fix linting, apply review comments and add forgotten package-lock.json change

* remove typegen.sh and move simpler command to package.json

* Move things around, remove babel and rollup

* Update packages

* Add browser dist to eslintignore

Co-authored-by: Arrowana <8245419+Arrowana@users.noreply.github.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-10 22:30:13 +02:00
dependabot[bot] 25b51bc2a0
build(deps-dev): bump dotenv from 9.0.0 to 9.0.1 in /token-lending/js (#1690)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 9.0.0 to 9.0.1.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 13:49:55 +00:00
dependabot[bot] f0ad7b3d5f
build(deps): bump @solana/spl-token in /token-lending/js (#1688)
Bumps [@solana/spl-token](https://github.com/solana-labs/solana-program-library) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/solana-labs/solana-program-library/releases)
- [Commits](https://github.com/solana-labs/solana-program-library/compare/@solana/spl-token@v0.1.3...@solana/spl-token@v0.1.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 13:03:57 +00:00
dependabot[bot] 2522d937d2
build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 in /token-swap/js (#1689)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 13:01:45 +00:00
Jon Cinque d68608c440
stake-pool: Re-enable tests, avoid warping so much (#1687) 2021-05-10 12:33:56 +00:00
dependabot[bot] c6a9446b17
build(deps-dev): bump @rollup/plugin-commonjs in /token-lending/js (#1684)
Bumps [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/HEAD/packages/commonjs) from 18.0.0 to 19.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Changelog](https://github.com/rollup/plugins/blob/master/packages/commonjs/CHANGELOG.md)
- [Commits](https://github.com/rollup/plugins/commits/commonjs-v19.0.0/packages/commonjs)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-10 12:27:05 +00:00
drbh 0ac20fcddf incorrect capitalization 2021-05-08 18:50:24 -07:00
drbh 9ca1c6e8f2 adjust typos and proper nouns on naming service page 2021-05-08 18:50:24 -07:00
Tyera Eulberg 5a5f129694
Ensure only docs files are modified (#1682) 2021-05-08 17:25:46 -06:00
Tyera Eulberg 13689ac2dd
Account with 2 Cs (#1680) 2021-05-08 19:18:32 +00:00
Christian Machacek 18d96ffce6 Fix cross-program-invocation C example
Correctly check if deriving the PDA with the given seed was successful.
Don't pass the system program pubkey to the allocate instruction: the first account passed must be the one to be allocated.
2021-05-08 09:58:39 -07:00
jordansexton f0b1cec4d8 stake-pool: minor typo fix 2021-05-07 13:50:35 -05:00
dependabot[bot] cfc6c582ff
build(deps): bump lodash from 4.17.19 to 4.17.21 in /token-swap/js (#1674)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-07 09:55:28 +00:00
dependabot[bot] 090ecefa46
build(deps): bump lodash from 4.17.20 to 4.17.21 in /token-lending/js (#1672)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-07 09:14:28 +00:00
Trent Nelson 9482f8d4e3 token/js: Bump version to v0.1.4 2021-05-07 06:39:04 +00:00
jordansexton 1526301d0d ran cargo fmt 2021-05-06 23:32:14 -05:00
Leonard G 3045d7b1df
Flashloan for token lending (#1444)
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: Jordan Sexton <jordan@jordansexton.com>
2021-05-06 23:27:41 -05:00
dependabot[bot] ea4b7e62fc
build(deps-dev): bump @typescript-eslint/eslint-plugin in /token/js (#1669)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.17.0 to 4.22.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.1/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-06 10:51:41 +00:00
dependabot[bot] 51cc3ed6fe
build(deps): bump @babel/runtime from 7.13.10 to 7.14.0 in /token/js (#1668)
Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.13.10 to 7.14.0.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.14.0/packages/babel-runtime)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-06 10:15:04 +00:00
dependabot[bot] 9aa238e0b4
build(deps-dev): bump @rollup/plugin-node-resolve in /token/js (#1667)
Bumps [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve) from 11.2.0 to 13.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Changelog](https://github.com/rollup/plugins/blob/master/packages/node-resolve/CHANGELOG.md)
- [Commits](https://github.com/rollup/plugins/commits/commonjs-v13.0.0/packages/node-resolve)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-06 09:40:44 +00:00
Michael Vines 00eb817073
Update token.md 2021-05-05 21:06:48 -07:00
dependabot[bot] 4e1892adba
build(deps-dev): bump dotenv from 8.2.0 to 9.0.0 in /token-lending/js (#1666)
Bumps [dotenv](https://github.com/motdotla/dotenv) from 8.2.0 to 9.0.0.
- [Release notes](https://github.com/motdotla/dotenv/releases)
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/motdotla/dotenv/compare/v8.2.0...v9.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-06 00:07:46 +00:00
dependabot[bot] 3714c70d12
build(deps): bump @solana/web3.js in /token-lending/js (#1665)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.9.0...v1.9.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-05 23:33:23 +00:00
dependabot[bot] a05fd7185d
build(deps-dev): bump @types/node in /token-lending/js (#1664)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.0.1 to 15.0.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-05 22:58:30 +00:00
dependabot[bot] cf2fcde121
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1663)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.22.0 to 4.22.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.1/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-05 22:22:49 +00:00
Trent Nelson 3d04aa0109 chore: add negative test for ATA creation with off-curve owner 2021-05-05 15:48:59 -06:00
Trent Nelson 7320cf404b fix: reject off-curve owners during ATA creation 2021-05-05 15:48:59 -06:00
Trent Nelson 975b524487 chore: bump solana web3 to v1.9.1 2021-05-05 15:48:59 -06:00
Michael Vines a539ef021f Explicitly call out the --decimals argument to `spl-token create-token` 2021-05-05 08:47:55 -07:00
Jon Cinque 1efc90c5c9
stake-pool: Update docs for all new features (#1651)
The stake pool program changed a lot, but the docs did not.  Bring them
up to speed!
2021-05-05 16:14:24 +02:00
dependabot[bot] 0ce5b41b9f
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1661)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.22.0 to 4.22.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.1/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-05 09:41:51 +00:00
Trent Nelson 1f36ca301b Bump solana crates to v1.6.7 2021-05-05 04:39:49 +00:00
Michael Vines 4068b77f53 Add name service to sidebar 2021-05-04 10:20:01 -07:00
Solana Maintainers 512497aa39 use cleanup 2021-05-04 10:12:05 -07:00
Solana Maintainers d9fd11a8f3 Add program id 2021-05-04 10:12:05 -07:00
dependabot[bot] 9e4764faf7
build(deps-dev): bump rollup from 2.46.0 to 2.47.0 in /token-lending/js (#1658)
Bumps [rollup](https://github.com/rollup/rollup) from 2.46.0 to 2.47.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.46.0...v2.47.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-04 09:36:09 +00:00
Lcchy 0ed080a50f
Add name-service program and js bindings (#1600) 2021-05-04 00:07:11 +00:00
Jon Cinque 3dd6767297
stake-pool: Update versions for crate deployment (#1657) 2021-05-03 20:50:49 +00:00
dependabot[bot] b99c9b375c
build(deps): bump @solana/web3.js in /token-lending/js (#1655)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.7.1 to 1.9.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.7.1...v1.9.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-03 11:24:25 +00:00
Jon Cinque 9c63bc0b06
stake-pool-cli: All sorts of fixes (#1650)
While going back through the docs, I ended up doing a lot of the stake
pool CLI items:

* Deposit / withdraw command: Use associated token account by default
* Create command: Allow passing the stake pool and mint keypair (useful
  for testing)
* Create command: Split the transaction for pool creation (required to get under the
  transaction size limit)
* Add / remove validator command: take a validator vote account rather than stake
  account, which makes integration from outside tools a lot simpler
* Update command: add a `--force` flag to force the update
* Update command: add a `--no-merge` flag to not merge while updating
  (useful to allow the pool to work, even if the transient stake
  accounts are unmergeable)
* Withdraw: Add `--use-reserve` flag to withdraw from reserve
* Withdraw: Add `--vote-account` arg to specify which validator to
  withdraw from
2021-05-03 11:47:24 +02:00
dependabot[bot] 5a357a50df
build(deps): bump @solana/web3.js in /token-lending/js (#1648)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.7.0 to 1.7.1.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.7.0...v1.7.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 09:48:42 +00:00
Jon Cinque 0f4f2b8de9
token-swap: Fix slippage on withdraw tokens (#1637)
* token-swap: Fix withdrawal all tokens slippage

When withdrawing, the slippage check is done before `min`ing the token a
and b amounts, which makes it possible to ignore the desired slippage,
and lose out on a lot more than expected.

This has an additional knock-on effect. When burning all of the pool
tokens, it becomes impossible to ever use it again.

* Check for slippage after getting the actual amount that would be
  traded
* Re-initialize the pool token amount on the next deposit if all pool
  tokens were burned

Fixes #1629

* Fmt + clippy

* Deposit one side on 0 pool tokens just gives new supply back
2021-04-29 14:26:47 +02:00
dependabot[bot] 60ef11e26b
build(deps-dev): bump rollup from 2.45.2 to 2.46.0 in /token-lending/js (#1644)
Bumps [rollup](https://github.com/rollup/rollup) from 2.45.2 to 2.46.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.45.2...v2.46.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-29 09:51:59 +00:00
Jordan Sexton 5e320ba976
lending: cross collateral / cross liquidity support (#1441) 2021-04-28 20:55:33 -05:00
dependabot[bot] 636407d7a9
build(deps-dev): bump @types/node in /token-lending/js (#1642)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.0.0 to 15.0.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-28 09:41:15 +00:00
Jon Cinque 11e207cc85
stake-pool: Add user transfer authority on withdraw (#1640)
The stake pool expects pool tokens to be delegated to the withdraw
authority before performing a withdrawal. If a user delegates too many
tokens to the withdraw authority, anyone else can take the rest of their
tokens by doing their own withdrawal.

Delegate pool tokens to an ephemeral keypair and sign with that.
2021-04-27 12:53:46 +00:00
Jon Cinque 14bdbdc3ac
stake-pool: Add ability to remove a validator that has deactivating transient stake (#1624)
* Add status enum

* Add ability to remove validator with transient stake

* Only account validator stake if active

* Fix merge conflicts
2021-04-27 13:24:39 +02:00
dependabot[bot] 7d666b86ce
build(deps): bump @solana/web3.js in /token-lending/js (#1639)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.5.0 to 1.7.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.5.0...v1.7.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-27 09:36:21 +00:00
dependabot[bot] 81ab529311
build(deps-dev): bump @types/node in /token-lending/js (#1638)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.41 to 15.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-27 09:35:28 +00:00
Tyera Eulberg c9a5289aa0
Add airdrop help to token docs (#1636) 2021-04-26 20:51:43 +00:00
Jon Cinque ca6d57991a
token-swap js: Fix arg list in ts / flow (#1633) 2021-04-26 20:21:25 +00:00
Tyera Eulberg 99aaab0993
docs: specify mint in spl-token balance examples (#1634) 2021-04-26 20:20:16 +00:00
dependabot[bot] 1e28a427a4
build(deps-dev): bump eslint from 7.24.0 to 7.25.0 in /token-lending/js (#1631)
Bumps [eslint](https://github.com/eslint/eslint) from 7.24.0 to 7.25.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.24.0...v7.25.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-26 11:09:53 +00:00
Jon Cinque 61a53abf6f
stake-pool: Add ability to withdraw from reserve if no stake available (#1627) 2021-04-23 23:55:16 +02:00
Michael Vines 1e47030549 Update SPL to Solana v1.6.6 2021-04-23 13:39:51 -07:00
Trent Nelson 9ad4168253
token-cli: bump version to 2.0.11 2021-04-23 01:53:28 -06:00
Trent Nelson dfc5cc5a23 token-cli: Fix ATA creation in offline mode 2021-04-23 07:42:45 +00:00
Jon Cinque c149b0a46e
stake-pool: Add depositor key on init, required on deposit (#1616)
* stake-pool: Add depositor key on init, required on deposit

Some stake pools need to be private, and not allow outside depositors.

Enhance the existing deposit authority in the stake pool be configurable
on initialization, and then require its signature on deposit.

The existing deposit authority is a program address, making deposits
permissionless. This allows a pool creator to set their own deposit_authority on
initialization. In a great turn of events, almost everything else works
the same way!

Here's the current workflow for deposit, where the user calls
stake_program::authorize and stake_pool::deposit in the same
transaction:

* stake_program::authorize assigns staker and withdraw authority to the
  stake pool deposit authority
* stake_pool::deposit
    - uses the deposit authority to assign authority on the deposited
  stake account to the stake pool withdraw authority
    - uses the withdraw authority to merge the deposited stake into the validator stake

The deposit authority must "sign" the transaction in order to reassign
authority to the withdraw authority. Currently, as a program address, it
can just do that. With this change, if the deposit authority is set
during initialization, then that deposit authority must sign the
instruction.

There's also a little update for ease-of-use to always do the
stake_program::authorize in the same transaction as stake_pool::deposit.
This way, in case someone tries to deposit into a forbidden stake pool, the
whole transaction will bail and their stake will stay as theirs.

* Address review feedback

* Fix rebase issues
2021-04-22 21:34:41 +02:00
Jon Cinque 804a61e558
stake-pool: Increase lower limit for increase-validator-stake (#1620)
* stake-pool: Increase lower limit for increase-validator-stake

* Update test amounts in line with limit
2021-04-22 20:49:30 +02:00
Jon Cinque 3613ffe3b0
hotfix: ignore tests that break with tip of 1.6 (#1622) 2021-04-22 12:30:47 +00:00
Jon Cinque 08c4cb530a
stake-pool-cli: Add increase / decrease validator stake (#1619) 2021-04-22 00:20:35 +00:00
Jon Cinque fdba05714d
stake-pool: Add merging transient stakes in update (#1618)
* Add check for transient stake account activation on removal

* Add proper merging logic during update

* Format + clippy

* Add max possible validators

* Disallow removal for any transient stake state

* Reduce number of accounts for BPF instruction usage
2021-04-22 01:41:15 +02:00
Jon Cinque 53c86493e6
stake-pool: Add reserve stake and decrease / increase validator stake instruction (#1617)
* Add reserve stake account

* Add decrease validator stake instruction

* Cargo fmt

* Add increase instruction

* Add more increase tests

* Fix set fee tests

* Fix clippy in tests

* Add test-bpf feature to increase / decrease tests
2021-04-21 22:20:27 +02:00
Jon Cinque 40ebfc6917
stake-pool: Set fee (#1604)
* stake-pool: Add set_fee instruction

* Add more tests

* Add set-fee CLI instruction

* Update documentation

* Cargo fmt

* Re-format

* Fix clippy
2021-04-21 14:20:55 +02:00
Jon Cinque 30671aa5b3
stake-pool: Rework add / remove validator to not use pool tokens (#1581)
* Rework remove

* Add tests

* Transition to checked math

* Update CLI for new types / instructions

* Cargo fmt

* Rename voter_pubkey -> vote_account_address

* Remove max check

* Update validator balance test
2021-04-21 13:06:43 +02:00
dependabot[bot] cf8eeb0720
build(deps-dev): bump @babel/cli from 7.13.10 to 7.13.16 in /token/js (#1615)
Bumps [@babel/cli](https://github.com/babel/babel/tree/HEAD/packages/babel-cli) from 7.13.10 to 7.13.16.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.16/packages/babel-cli)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-21 08:56:11 +00:00
Jack May df994bf426
Fix float measurements (#1613)
* Fix float measurements

* add u64 divide
2021-04-21 00:33:49 +00:00
dependabot[bot] 6fee08be2f
build(deps): bump @solana/web3.js in /token-lending/js (#1612)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.4.0...v1.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-20 09:36:54 +00:00
Jack May a5c4b1e071
Switch shared-mem tests to programtest (#1611) 2021-04-19 11:14:23 -07:00
dependabot[bot] 589da55e29
build(deps): bump @solana/web3.js in /token-lending/js (#1609)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.2.7 to 1.4.0.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.2.7...v1.4.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-19 10:58:52 +00:00
Michael Vines ebc16782bb clippy 2021-04-18 20:27:27 -07:00
Michael Vines 18468b513f Update to Rust 1.51.0 2021-04-18 20:27:27 -07:00
dependabot[bot] 7a0e5aa14e
build(deps-dev): bump @types/node in /token-lending/js (#1603)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.37 to 14.14.41.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-16 09:34:54 +00:00
Trent Nelson 9dd807c893 docs: specify mint in `spl-token transfer` examples 2021-04-16 05:42:17 +00:00
Jon Cinque 71e5e556c4
stake-pool: Assess fee as a percentage of rewards (#1597)
* stake-pool: Collect fee every epoch as proportion of rewards

* Add more complete tests

* Update docs
2021-04-15 12:10:17 +02:00
dependabot[bot] d3e26d089b
build(deps-dev): bump @types/eslint in /token-lending/js (#1599)
Bumps [@types/eslint](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/eslint) from 7.2.9 to 7.2.10.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/eslint)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-15 09:37:10 +00:00
dependabot[bot] 48a0f81ab6
build(deps-dev): bump eslint-plugin-prettier in /token-lending/js (#1598)
Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-15 09:32:54 +00:00
B 9281b6e828
feat: adjust fee constraints (#1596) 2021-04-14 13:33:34 -05:00
Trent Nelson 96901b1299 token-cli: sign_only gates for `transfer` 2021-04-14 12:13:52 -06:00
Trent Nelson b8a773fddd token-cli: sign_only gates for `authorize` 2021-04-14 12:13:52 -06:00
Trent Nelson 4374d8dee4 token-cli: Fix transfer to multisig ATAs 2021-04-14 12:13:52 -06:00
Trent Nelson 6a52ba7d92 token-cli: sign_only gates for `create-account` 2021-04-14 12:13:52 -06:00
dependabot[bot] 24ea32aa48
build(deps-dev): bump rollup from 2.45.1 to 2.45.2 in /token-lending/js (#1594)
Bumps [rollup](https://github.com/rollup/rollup) from 2.45.1 to 2.45.2.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.45.1...v2.45.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 09:36:55 +00:00
dependabot[bot] 1ff9f789e7
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1591)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.21.0 to 4.22.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-13 10:10:18 +00:00
dependabot[bot] 529b070e2b
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1590)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.21.0 to 4.22.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-13 09:37:18 +00:00
dependabot[bot] 13f8430b77
build(deps): bump @solana/web3.js in /token-lending/js (#1588)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.2.6...v1.2.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 11:33:05 +00:00
dependabot[bot] b581ab3319
build(deps-dev): bump @types/eslint in /token-lending/js (#1587)
Bumps [@types/eslint](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/eslint) from 7.2.8 to 7.2.9.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/eslint)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 11:30:42 +00:00
dependabot[bot] 31d5640706
build(deps-dev): bump rollup from 2.45.0 to 2.45.1 in /token-lending/js (#1585)
Bumps [rollup](https://github.com/rollup/rollup) from 2.45.0 to 2.45.1.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.45.0...v2.45.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 10:58:36 +00:00
dependabot[bot] 34571b624f
build(deps-dev): bump eslint from 7.23.0 to 7.24.0 in /token-lending/js (#1586)
Bumps [eslint](https://github.com/eslint/eslint) from 7.23.0 to 7.24.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.23.0...v7.24.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 10:56:42 +00:00
Jon Cinque 2b3f71ead5
stake-pool: Add rebalancing instruction interface (#1563)
* stake-pool: Add rebalancing instruction interface

* Address feedback

* Rename again

* Ignore rustdoc code
2021-04-09 12:32:21 +02:00
dependabot[bot] 2ef336fd0a
build(deps-dev): bump rollup from 2.44.0 to 2.45.0 in /token-lending/js (#1584)
Bumps [rollup](https://github.com/rollup/rollup) from 2.44.0 to 2.45.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.44.0...v2.45.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-09 09:32:01 +00:00
Tyera Eulberg 78ab468781
Add to .gitignore 2021-04-08 17:58:07 -06:00
dependabot[bot] 0d5146e30c
build(deps-dev): bump typescript in /token-lending/js (#1582)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.3 to 4.2.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-08 09:38:48 +00:00
dependabot[bot] 34583bf748
build(deps-dev): bump @typescript-eslint/eslint-plugin (#1577)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.20.0 to 4.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 10:08:00 +00:00
dependabot[bot] fa5c34dc84
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1576)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.20.0 to 4.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 09:35:07 +00:00
dependabot[bot] 4d1bb013fb
build(deps-dev): bump eslint-plugin-flowtype in /token/js (#1575)
Bumps [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype) from 5.3.1 to 5.6.0.
- [Release notes](https://github.com/gajus/eslint-plugin-flowtype/releases)
- [Commits](https://github.com/gajus/eslint-plugin-flowtype/compare/v5.3.1...v5.6.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 09:12:51 +00:00
Tyera Eulberg 3ab19ba514
Bump memo to v3.0.1 (#1574) 2021-04-05 14:22:05 -06:00
Jon Cinque e8f59e42ba
token-swap: Bump crate version to 2.1.0 for release (#1573) 2021-04-05 21:56:38 +02:00
Jon Cinque 7f89183c0d
stake-pool: Ensure zero pool token supply on init (#1572) 2021-04-05 20:06:40 +02:00
Michael Vines 17dd53d5e8 Break up the UpdateValidatorListBalance instructions over multiple transactions 2021-04-05 08:50:57 -07:00
Jon Cinque 8f325dcd2d
math: Improve sqrt using bit-wise operations (#1562)
* math: Improve sqrt guess using bit-wise operations

* Run fmt and bump up instruction for failed test

* Bump up compute cost from CI failure

* Update CI version of toolchain

* Address feedback
2021-04-05 14:48:27 +02:00
dependabot[bot] 0e2b08066b
build(deps): bump @solana/web3.js in /token-lending/js (#1571)
Bumps [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/solana-labs/solana-web3.js/releases)
- [Changelog](https://github.com/solana-labs/solana-web3.js/blob/master/.releaserc.json)
- [Commits](https://github.com/solana-labs/solana-web3.js/compare/v1.2.5...v1.2.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-05 10:31:13 +00:00
Tyera Eulberg c01665832a
Ignore compute-budget test to unblock bpf-tools v1.5 (#1569) 2021-04-03 18:36:00 +00:00
Michael Vines ee52f1d499 Reimplement `spl-stake-pool list` command to use the StakePool/ValidatorList as the primary source of information 2021-04-02 16:27:42 -07:00
Jon Cinque 092432f1e1
stake-pool: Separate manager from owner (#1560)
* stake-pool: Separate manager from owner

* Add manager pubkey to stake pool
* Differentiate manager functions from owner functions
* Include a `set_manager` function to be used by the owner
* Change the term `owner` to `authority` in the CLI for clarity

* Rename manager -> staker and owner -> manager

* Split staker, manager, and token owner in CLI

* "Do not disturb the boss"
2021-04-02 10:56:12 +02:00
Jon Cinque f309df4f35
token-swap: Update package version to match crates (#1561) 2021-04-01 20:53:59 +02:00
383 changed files with 74763 additions and 24983 deletions

View File

@ -0,0 +1,59 @@
name: Binary Oracle Pair Pull Request
on:
pull_request:
paths:
- 'binary-oracle-pair/**'
- 'token/**'
push:
branches: [master]
paths:
- 'binary-oracle-pair/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh binary-oracle-pair

View File

@ -10,7 +10,34 @@ on:
- 'docs/**' - 'docs/**'
jobs: jobs:
all_github_action_checks: check_non_docs:
outputs:
run_all_github_action_checks: ${{ steps.check_files.outputs.run_all_github_action_checks }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: check modified files
id: check_files
run: |
echo "========== check paths of modified files =========="
echo "::set-output name=run_all_github_action_checks::true"
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
if [[ $file != docs/** ]]; then
echo "Found modified non-'docs' file(s)"
echo "::set-output name=run_all_github_action_checks::false"
break
fi
done < files.txt
all_github_action_checks:
runs-on: ubuntu-latest
needs: check_non_docs
if: needs.check_non_docs.outputs.run_all_github_action_checks == 'true'
steps: steps:
- run: echo "Done" - run: echo "Done"

View File

@ -0,0 +1,57 @@
name: Examples Pull Request
on:
pull_request:
paths:
- 'examples/rust/**'
push:
branches: [master]
paths:
- 'examples/rust/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh examples/rust

View File

@ -0,0 +1,59 @@
name: Feature Proposal Pull Request
on:
pull_request:
paths:
- 'feature-proposal/**'
- 'token/**'
push:
branches: [master]
paths:
- 'feature-proposal/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh feature-proposal

View File

@ -0,0 +1,59 @@
name: Governance Pull Request
on:
pull_request:
paths:
- 'governance/**'
- 'token/**'
push:
branches: [master]
paths:
- 'governance/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh governance

View File

@ -0,0 +1,57 @@
name: Libraries Pull Request
on:
pull_request:
paths:
- 'libraries/**'
push:
branches: [master]
paths:
- 'libraries/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh libraries

57
.github/workflows/pull-request-memo.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Memo Pull Request
on:
pull_request:
paths:
- 'memo/**'
push:
branches: [master]
paths:
- 'memo/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh memo

View File

@ -0,0 +1,57 @@
name: Name Service Pull Request
on:
pull_request:
paths:
- 'name-service/**'
push:
branches: [master]
paths:
- 'name-service/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh name-service

View File

@ -0,0 +1,57 @@
name: Record Pull Request
on:
pull_request:
paths:
- 'record/**'
push:
branches: [master]
paths:
- 'record/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh record

View File

@ -0,0 +1,57 @@
name: Shared Memory Pull Request
on:
pull_request:
paths:
- 'shared-memory/**'
push:
branches: [master]
paths:
- 'shared-memory/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh shared-memory

View File

@ -0,0 +1,59 @@
name: Stake Pool Pull Request
on:
pull_request:
paths:
- 'stake-pool/**'
- 'token/**'
push:
branches: [master]
paths:
- 'stake-pool/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh stake-pool

View File

@ -0,0 +1,90 @@
name: Token Lending Pull Request
on:
pull_request:
paths:
- 'token-lending/**'
- 'token/**'
push:
branches: [master]
paths:
- 'token-lending/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh token-lending
- name: Upload programs
uses: actions/upload-artifact@v2
with:
name: token-lending-programs
path: "target/deploy/*.so"
if-no-files-found: error
js-test:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-test-bpf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('token-lending/js/package-lock.json') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: token-lending-programs
path: target/deploy
- run: ./ci/js-test-token-lending.sh

View File

@ -0,0 +1,154 @@
name: Token Swap Pull Request
on:
pull_request:
paths:
- 'token-swap/**'
- 'token/**'
- 'libraries/math/**'
push:
branches: [master]
paths:
- 'token-swap/**'
- 'token/**'
- 'libraries/math/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh token-swap
- name: Build production version
run: |
cargo +"$RUST_STABLE" build-bpf \
--manifest-path=token-swap/program/Cargo.toml \
--features production \
--bpf-out-dir target/deploy-production
env:
SWAP_PROGRAM_OWNER_FEE_ADDRESS: HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN
- name: Move production version for upload
run: |
mv target/deploy-production/spl_token_swap.so target/deploy/spl_token_swap_production.so
- name: Upload programs
uses: actions/upload-artifact@v2
with:
name: token-swap-programs
path: "target/deploy/*.so"
if-no-files-found: error
js-test:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-test-bpf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('token-swap/js/package-lock.json') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: token-swap-programs
path: target/deploy
- run: ./ci/js-test-token-swap.sh
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: token-swap-fuzz-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/cargo-hfuzz
~/.cargo/bin/cargo-honggfuzz
key: cargo-fuzz-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
restore-keys: |
solana-
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Run fuzz target
run: ./ci/fuzz.sh token-swap-instructions 30 # 30 seconds, just to check everything is ok

View File

@ -0,0 +1,93 @@
name: Token Pull Request
on:
pull_request:
paths:
- 'associated-token-account/**'
- 'token/**'
push:
branches: [master]
paths:
- 'associated-token-account/**'
- 'token/**'
jobs:
cargo-test-bpf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Build and test
run: ./ci/cargo-test-bpf.sh token
- name: Build and test
run: ./ci/cargo-test-bpf.sh associated-token-account
- name: Upload programs
uses: actions/upload-artifact@v2
with:
name: token-programs
path: "target/deploy/*.so"
if-no-files-found: error
js-test:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-test-bpf
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('token/js/package-lock.json') }}
restore-keys: |
node-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: token-programs
path: target/deploy
- run: ./ci/js-test-token.sh

View File

@ -16,10 +16,6 @@ jobs:
- rustfmt - rustfmt
- clippy - clippy
- cargo-build-test - cargo-build-test
- js-test-token
- js-test-token-swap
- js-test-token-lending
- fuzz
steps: steps:
- run: echo "Done" - run: echo "Done"
@ -128,135 +124,3 @@ jobs:
- name: Build and test - name: Build and test
run: ./ci/cargo-build-test.sh run: ./ci/cargo-build-test.sh
- name: Upload programs
uses: actions/upload-artifact@v2
with:
name: programs
path: "target/deploy/*.so"
if-no-files-found: error
js-test-token:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-build-test
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: programs
path: target/bpfel-unknown-unknown/release
- run: ./ci/js-test-token.sh
js-test-token-swap:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-build-test
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-swap-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-swap-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: programs
path: target/deploy
- run: ./ci/js-test-token-swap.sh
js-test-token-lending:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
needs: cargo-build-test
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-lending-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-lending-
- name: Download programs
uses: actions/download-artifact@v2
with:
name: programs
path: target/deploy
- run: ./ci/js-test-token-lending.sh
fuzz:
runs-on: ubuntu-latest
strategy:
matrix:
fuzz_target: [token-swap-instructions]
steps:
- uses: actions/checkout@v2
- name: Set env vars
run: |
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-fuzz-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/cargo-hfuzz
~/.cargo/bin/cargo-honggfuzz
key: cargo-fuzz-bins-${{ runner.os }}
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}
restore-keys: |
solana-
- name: Install dependencies
run: |
./ci/install-build-deps.sh
./ci/install-program-deps.sh
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Run fuzz target
run: ./ci/fuzz.sh ${{ matrix.fuzz_target }} 30 # 30 seconds, just to check everything is ok

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ node_modules
hfuzz_target hfuzz_target
hfuzz_workspace hfuzz_workspace
**/*.so **/*.so
**/.DS_Store
test-ledger

View File

@ -4,10 +4,21 @@
# #
# https://doc.mergify.io/ # https://doc.mergify.io/
pull_request_rules: pull_request_rules:
- name: label changes from community
conditions:
- author≠@core-contributors
- author≠mergify[bot]
- author≠dependabot[bot]
actions:
label:
add:
- community
- name: automatic merge (squash) on CI success - name: automatic merge (squash) on CI success
conditions: conditions:
- check-success=Travis CI - Pull Request - check-success=Travis CI - Pull Request
- check-success=all_github_action_checks - check-success=all_github_action_checks
- "#status-failure=0"
- "#status-neutral=0"
- label=automerge - label=automerge
- author≠@dont-squash-my-commits - author≠@dont-squash-my-commits
actions: actions:
@ -18,6 +29,8 @@ pull_request_rules:
conditions: conditions:
- check-success=Travis CI - Pull Request - check-success=Travis CI - Pull Request
- check-success=all_github_action_checks - check-success=all_github_action_checks
- "#status-failure=0"
- "#status-neutral=0"
- label=automerge - label=automerge
- author=@dont-squash-my-commits - author=@dont-squash-my-commits
actions: actions:

1362
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -9,14 +9,16 @@ members = [
"examples/rust/transfer-lamports", "examples/rust/transfer-lamports",
"feature-proposal/program", "feature-proposal/program",
"feature-proposal/cli", "feature-proposal/cli",
"governance/program",
"libraries/math", "libraries/math",
"memo/program", "memo/program",
"name-service/program",
"record/program", "record/program",
"shared-memory/program", "shared-memory/program",
"stake-pool/cli", "stake-pool/cli",
"stake-pool/program", "stake-pool/program",
"token-lending/cli",
"token-lending/program", "token-lending/program",
"token-lending/client",
"token-swap/program", "token-swap/program",
"token-swap/program/fuzz", "token-swap/program/fuzz",
"token/cli", "token/cli",
@ -29,3 +31,6 @@ exclude = [
"themis/program_ristretto", "themis/program_ristretto",
"token/perf-monitor", # TODO: Rework perf-monitor to use solana-program-test, avoiding the need to link directly with the BPF VM "token/perf-monitor", # TODO: Rework perf-monitor to use solana-program-test, avoiding the need to link directly with the BPF VM
] ]
[profile.dev]
split-debuginfo = "unpacked"

View File

@ -12,12 +12,12 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.4"
spl-token = { version = "3.1", path = "../../token/program", features = ["no-entrypoint"] } spl-token = { version = "3.1", path = "../../token/program", features = ["no-entrypoint"] }
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.4"
solana-sdk = "1.6.2" solana-sdk = "1.7.4"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -34,7 +34,7 @@ pub fn get_associated_token_address(
wallet_address: &Pubkey, wallet_address: &Pubkey,
spl_token_mint_address: &Pubkey, spl_token_mint_address: &Pubkey,
) -> Pubkey { ) -> Pubkey {
get_associated_token_address_and_bump_seed(&wallet_address, &spl_token_mint_address, &id()).0 get_associated_token_address_and_bump_seed(wallet_address, spl_token_mint_address, &id()).0
} }
fn get_associated_token_address_and_bump_seed_internal( fn get_associated_token_address_and_bump_seed_internal(

View File

@ -31,10 +31,10 @@ pub fn process_instruction(
let rent_sysvar_info = next_account_info(account_info_iter)?; let rent_sysvar_info = next_account_info(account_info_iter)?;
let (associated_token_address, bump_seed) = get_associated_token_address_and_bump_seed_internal( let (associated_token_address, bump_seed) = get_associated_token_address_and_bump_seed_internal(
&wallet_account_info.key, wallet_account_info.key,
&spl_token_mint_info.key, spl_token_mint_info.key,
program_id, program_id,
&spl_token_program_id, spl_token_program_id,
); );
if associated_token_address != *associated_token_account_info.key { if associated_token_address != *associated_token_account_info.key {
msg!("Error: Associated address does not match seed derivation"); msg!("Error: Associated address does not match seed derivation");
@ -62,7 +62,7 @@ pub fn process_instruction(
); );
invoke( invoke(
&system_instruction::transfer( &system_instruction::transfer(
&funder_info.key, funder_info.key,
associated_token_account_info.key, associated_token_account_info.key,
required_lamports, required_lamports,
), ),
@ -84,23 +84,23 @@ pub fn process_instruction(
associated_token_account_info.clone(), associated_token_account_info.clone(),
system_program_info.clone(), system_program_info.clone(),
], ],
&[&associated_token_account_signer_seeds], &[associated_token_account_signer_seeds],
)?; )?;
msg!("Assign the associated token account to the SPL Token program"); msg!("Assign the associated token account to the SPL Token program");
invoke_signed( invoke_signed(
&system_instruction::assign(associated_token_account_info.key, &spl_token_program_id), &system_instruction::assign(associated_token_account_info.key, spl_token_program_id),
&[ &[
associated_token_account_info.clone(), associated_token_account_info.clone(),
system_program_info.clone(), system_program_info.clone(),
], ],
&[&associated_token_account_signer_seeds], &[associated_token_account_signer_seeds],
)?; )?;
msg!("Initialize the associated token account"); msg!("Initialize the associated token account");
invoke( invoke(
&spl_token::instruction::initialize_account( &spl_token::instruction::initialize_account(
&spl_token_program_id, spl_token_program_id,
associated_token_account_info.key, associated_token_account_info.key,
spl_token_mint_info.key, spl_token_mint_info.key,
wallet_account_info.key, wallet_account_info.key,

View File

@ -13,16 +13,16 @@ test-bpf = []
[dependencies] [dependencies]
num-derive = "0.3" num-derive = "0.3"
num-traits = "0.2" num-traits = "0.2"
solana-program = "1.6.2" solana-program = "1.7.4"
spl-token = { version = "3.0", path = "../../token/program", features = [ "no-entrypoint" ] } spl-token = { version = "3.1", path = "../../token/program", features = [ "no-entrypoint" ] }
thiserror = "1.0" thiserror = "1.0"
uint = "0.8" uint = "0.9"
arbitrary = { version = "0.4", features = ["derive"], optional = true } arbitrary = { version = "0.4", features = ["derive"], optional = true }
borsh = "0.8.2" borsh = "0.9.0"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.4"
solana-sdk = "1.6.2" solana-sdk = "1.7.4"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -421,7 +421,7 @@ impl Processor {
authority_account_info.clone(), authority_account_info.clone(),
user_transfer_authority_info.clone(), user_transfer_authority_info.clone(),
amount, amount,
&pool_account_info.key, pool_account_info.key,
pool.bump_seed, pool.bump_seed,
)?; )?;
@ -446,7 +446,7 @@ impl Processor {
authority_account_info.clone(), authority_account_info.clone(),
user_transfer_authority_info.clone(), user_transfer_authority_info.clone(),
amount, amount,
&pool_account_info.key, pool_account_info.key,
pool.bump_seed, pool.bump_seed,
)?; )?;
@ -477,7 +477,7 @@ impl Processor {
authority_account_info.clone(), authority_account_info.clone(),
user_transfer_authority_info.clone(), user_transfer_authority_info.clone(),
possible_withdraw_amount, possible_withdraw_amount,
&pool_account_info.key, pool_account_info.key,
pool.bump_seed, pool.bump_seed,
)?; )?;
@ -489,7 +489,7 @@ impl Processor {
authority_account_info.clone(), authority_account_info.clone(),
user_transfer_authority_info.clone(), user_transfer_authority_info.clone(),
amount, amount,
&pool_account_info.key, pool_account_info.key,
pool.bump_seed, pool.bump_seed,
)?; )?;

View File

@ -14,10 +14,6 @@ set -x
# Build all C examples # Build all C examples
make -C examples/c make -C examples/c
# Build/test all BPF programs
cargo +"$rust_stable" test-bpf -- --nocapture
rm -rf target/debug # Prevents running out of space on github action runners
# Build/test all host crates # Build/test all host crates
cargo +"$rust_stable" build cargo +"$rust_stable" build
cargo +"$rust_stable" test -- --nocapture cargo +"$rust_stable" test -- --nocapture
@ -29,13 +25,6 @@ cargo +"$rust_stable" run --manifest-path=utils/test-client/Cargo.toml
# client_ristretto disabled because it requires RpcBanksService, which is no longer supported. # client_ristretto disabled because it requires RpcBanksService, which is no longer supported.
#cargo +"$rust_stable" test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture #cargo +"$rust_stable" test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture
SWAP_PROGRAM_OWNER_FEE_ADDRESS="HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN" \
cargo +"$rust_stable" build-bpf \
--manifest-path=token-swap/program/Cargo.toml \
--features production \
--bpf-out-dir target/deploy-production
mv target/deploy-production/spl_token_swap.so target/deploy/spl_token_swap_production.so
# # Check generated C headers # # Check generated C headers
# cargo run --manifest-path=utils/cgen/Cargo.toml # cargo run --manifest-path=utils/cgen/Cargo.toml
# #

42
ci/cargo-test-bpf.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
source ./ci/rust-version.sh stable
source ./ci/solana-version.sh
export RUSTFLAGS="-D warnings"
export RUSTBACKTRACE=1
usage() {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
echo "Usage: $0 [program-directory]"
exit $exitcode
}
program_directory=$1
if [[ -z $program_directory ]]; then
usage "No program directory provided"
fi
set -x
cd $program_directory
run_dir=$(pwd)
if [[ -d $run_dir/program ]]; then
# Build/test just one BPF program
cd $run_dir/program
cargo +"$rust_stable" test-bpf -- --nocapture
else
# Build/test all BPF programs
for directory in $(ls -d $run_dir/*/); do
cd $directory
cargo +"$rust_stable" test-bpf -- --nocapture
done
fi

View File

@ -4,9 +4,10 @@ set -e
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
source ./ci/solana-version.sh install source ./ci/solana-version.sh install
npm install --global yarn
set -x set -x
cd token-lending/js cd token-lending/js
npm install yarn install --pure-lockfile
npm run lint yarn run lint
npm run build yarn run build
npm run start-with-test-validator

View File

@ -4,13 +4,10 @@ set -ex
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
source ./ci/solana-version.sh install source ./ci/solana-version.sh install
(cd token/js && npm install)
cd token-swap/js cd token-swap/js
npm install npm install
npm run lint npm run lint
npm run flow npm run build
npx tsc module.d.ts
npm run start-with-test-validator npm run start-with-test-validator
(cd ../../target/deploy && mv spl_token_swap_production.so spl_token_swap.so) (cd ../../target/deploy && mv spl_token_swap_production.so spl_token_swap.so)
SWAP_PROGRAM_OWNER_FEE_ADDRESS="HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN" npm run start-with-test-validator SWAP_PROGRAM_OWNER_FEE_ADDRESS="HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN" npm run start-with-test-validator

View File

@ -18,13 +18,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION" stable_version="$RUST_STABLE_VERSION"
else else
stable_version=1.50.0 stable_version=1.53.0
fi fi
if [[ -n $RUST_NIGHTLY_VERSION ]]; then if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION" nightly_version="$RUST_NIGHTLY_VERSION"
else else
nightly_version=2021-02-18 nightly_version=2021-06-09
fi fi

View File

@ -14,11 +14,10 @@
if [[ -n $SOLANA_VERSION ]]; then if [[ -n $SOLANA_VERSION ]]; then
solana_version="$SOLANA_VERSION" solana_version="$SOLANA_VERSION"
else else
solana_version=v1.5.15 solana_version=v1.7.3
fi fi
export solana_version="$solana_version" export solana_version="$solana_version"
export solana_docker_image=solanalabs/solana:"$solana_version"
export PATH="$HOME"/.local/share/solana/install/active_release/bin:"$PATH" export PATH="$HOME"/.local/share/solana/install/active_release/bin:"$PATH"
if [[ -n $1 ]]; then if [[ -n $1 ]]; then

View File

@ -8,6 +8,7 @@ module.exports = {
"token-lending", "token-lending",
"associated-token-account", "associated-token-account",
"memo", "memo",
"name-service",
"shared-memory", "shared-memory",
"stake-pool", "stake-pool",
"feature-proposal", "feature-proposal",

View File

@ -55,7 +55,7 @@ The [get_associated_token_address](https://docs.rs/spl-associated-token-account/
Rust function may be used by clients to derive the wallet's associated token address. Rust function may be used by clients to derive the wallet's associated token address.
The associated account address can be derived in Javascript with: The associated account address can be derived in TypeScript with:
```ts ```ts
import { PublicKey } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token'; import { TOKEN_PROGRAM_ID } from '@solana/spl-token';

View File

@ -62,7 +62,7 @@ Logging ends with the status of the instruction, one of:
For more information about exposing program logs on a node, head to the For more information about exposing program logs on a node, head to the
[developer [developer
docs](https://docs.solana.com/developing/deployed-programs/debugging#logging) docs](https://docs.solana.com/developing/on-chain-programs/debugging#logging)
### Compute Limits ### Compute Limits

57
docs/src/name-service.md Normal file
View File

@ -0,0 +1,57 @@
---
title: Name Service
---
A SPL program for issuing and managing ownership of: domain names, Solana Pubkeys, URLs, Twitter handles, ipfs cid's etc..
This program could be used for dns, pubkey etc lookups via a browser extension
for example, the goal is to create an easy way to identify Solana public keys
with various links.
Broader use cases are also imaginable.
Key points:
- A Name is a string that maps to a record (program derived account) which can hold data.
- Each name is of a certain class and has a certain owner, both are identified
by their pubkeys. The class of a name needs to sign the issuance of it.
- A name can have a parent name that is identified by the address of its record.
The owner of the parent name (when it exists) needs to sign the issuance of
the child name.
- The data of a name registry is controlled by the class keypair or, when it is
set to `Pubkey::default()`, by the name owner keypair.
- Only the owner can delete a name registry.
Remarks and use cases:
- Domain name declarations: One could arbitrarily set-up a class that we can call
Top-Level-Domain names. Names in this class can only be issued with the
permission of the class keypair, ie the administrator, who can enforce that
TLD names are of the type `".something"`. From then on one could create and
own the TLD `".sol"` and create a class of ".sol" sub-domains, administrating
the issuance of the `"something.sol"` sub-domains that way (by setting the
parent name to the address of the `".sol"` registry).
An off-chain browser extension could then, similarly to DNS, parse the user SPL
name service URL input and descend the chain of names, verifying that the names
exist with the correct parenthood, and finally use the data of the last child
name (or also a combination of the parents data) in order to resolve this call
towards a real DNS URL or any kind of data.
Although the ownership and class system makes the administration a given class
centralized, the creation of new classes is permissionless and as a class owner
any kind of decentralized governance signing program could be used.
- Twitter handles can be added as names of one specific name class. The class
authority of will therefore hold the right to add a Twitter handle name. This
enables the verification of Twitter accounts for example by asking the user to
tweet his pubkey or a signed message. A bot that holds the private issuing
authority key can then sign the Create instruction (with a metadata_authority
that is the tweeted pubkey) and send it back to the user who will then submit
it to the program.
In this case the class will still be able to control the data of the name registry, and not the user for example.
Therefore, another way of using this program would be to create a name
(`"verified-twitter-handles"` for example) with the `Pubkey::default()` class
and with the owner being the authority. That way verified Twitter names could be
issued as child names of this parent by the owner, leaving the user as being
able to modify the data of his Twitter name registry.

View File

@ -3,7 +3,7 @@ title: Stake Pool Program
--- ---
A program for pooling together SOL to be staked by an off-chain agent running A program for pooling together SOL to be staked by an off-chain agent running
a Delegation bot which redistributes the stakes across the network and tries a Delegation Bot which redistributes the stakes across the network and tries
to maximize censorship resistance and rewards. to maximize censorship resistance and rewards.
## Overview ## Overview
@ -14,7 +14,7 @@ inflation rate, total number of SOL staked on the network, and an individual
validators uptime and commission (fee). validators uptime and commission (fee).
Stake pools are an alternative method of earning staking rewards. This on-chain Stake pools are an alternative method of earning staking rewards. This on-chain
program pools together SOL to be staked by a manager, allowing SOL holders to program pools together SOL to be staked by a staker, allowing SOL holders to
stake and earn rewards without managing stakes. stake and earn rewards without managing stakes.
Additional information regarding staking and stake programming is available at: Additional information regarding staking and stake programming is available at:
@ -24,16 +24,18 @@ Additional information regarding staking and stake programming is available at:
## Motivation ## Motivation
This document is intended for stake pool managers who want to create or manage This document is intended for the main actors of the stake pool system:
stake pools, and users who want to provide staked SOL into an existing stake
pool. * manager: creates and manages the stake pool, earns fees, can update the fee, staker, and manager
* staker: adds and removes validators to the pool, rebalances stake among validators
* user: provides staked SOL into an existing stake pool
In its current iteration, the stake pool only processes totally active stakes. In its current iteration, the stake pool only processes totally active stakes.
Deposits must come from fully active stakes, and withdrawals return a fully Deposits must come from fully active stakes, and withdrawals return a fully
active stake account. active stake account.
This means that stake pool managers and users must be comfortable with creating This means that stake pool managers, stakers, and users must be comfortable with
and delegating stakes, which are more advanced operations than sending and creating and delegating stakes, which are more advanced operations than sending and
receiving SPL tokens and SOL. Additional information on stake operations are receiving SPL tokens and SOL. Additional information on stake operations are
available at: available at:
@ -46,27 +48,28 @@ like [Token Swap](token-swap.md).
## Operation ## Operation
A stake pool manager creates a stake pool and includes validators that will A stake pool manager creates a stake pool, and the staker includes validators that will
receive delegations from the pool by creating "validator stake accounts" and receive delegations from the pool by creating "validator stake accounts" and
activating a delegation on them. Once a validator stake account's delegation is activating a delegation on them. Once a validator stake account's delegation is
active, the stake pool manager adds it to the stake pool. active, the staker adds it to the stake pool.
At this point, users can participate with deposits. They must delegate a stake At this point, users can participate with deposits. They must delegate a stake
account to the one of the validators in the stake pool. Once it's active, the account to the one of the validators in the stake pool. Once it's active, the
user can deposit their stake into the pool in exchange for SPL staking derivatives user can deposit their stake into the pool in exchange for SPL staking derivatives
representing their fractional ownership in pool. A percentage of the user's representing their fractional ownership in pool. A percentage of the rewards
deposit goes to the pool manager as a fee. earned by the pool goes to the pool manager as a fee.
Over time, as the stake pool accrues staking rewards, the user's fractional Over time, as the stakes in the stake pool accrue staking rewards, the user's fractional
ownership will be worth more than their initial deposit. Whenever the user chooses, ownership will be worth more than their initial deposit. Whenever the user chooses,
they can withdraw their SPL staking derivatives in exchange for an activated stake. they can withdraw their SPL staking derivatives in exchange for an activated stake.
The stake pool manager can add and remove validators, or rebalance the pool by The stake pool staker can add and remove validators, or rebalance the pool by
withdrawing stakes from the pool, deactivating them, reactivating them on another decreasing the stake on a validator, waiting an epoch to move it into the stake
validator, then depositing back into the pool. pool's reserve account, then increasing the stake on another validator.
These manager operations require SPL staking derivatives and staked SOL, so the The staker operation to add a new validator requires roughly 1.003 SOL to create
stake pool manager will need liquidity on hand to properly manage the pool. the stake account on a validator, so the stake pool staker will need liquidity
on hand to fully manage the pool stakes.
## Background ## Background
@ -112,7 +115,7 @@ Keypair Path: ${HOME}/.config/solana/id.json
See [Solana clusters](https://docs.solana.com/clusters) for cluster-specific RPC URLs See [Solana clusters](https://docs.solana.com/clusters) for cluster-specific RPC URLs
```sh ```sh
solana config set --url https://devnet.solana.com solana config set --url https://api.devnet.solana.com
``` ```
#### Default Keypair #### Default Keypair
@ -130,32 +133,111 @@ Hardware Wallet URL (See [URL spec](https://docs.solana.com/wallet-guide/hardwar
solana config set --keypair usb://ledger/ solana config set --keypair usb://ledger/
``` ```
### Stake Pool Administrator Examples #### Run Locally
If you would like to test a stake pool locally without having to wait for stakes
to activate and deactivate, you can run the stake pool locally using the
`solana-test-validator` tool with shorter epochs, and pulling the current program
from devnet, testnet, or mainnet.
```sh
$ solana-test-validator -c poo1B9L9nR3CrcaziKVYVpRX6A9Y1LAXYasjjfCbApj -c 5TfMPP2zwrXWTUvkg5AG54QWpEkwjeBUhpP7x99kkvEj --url devnet --slots-per-epoch 32
$ solana config set --url http://127.0.0.1:8899
```
### Stake Pool Manager Examples
#### Create a stake pool #### Create a stake pool
The pool administrator manages the stake accounts in a stake pool, and in exchange The stake pool manager controls the stake pool from a high level, and in exchange
receives a fee in the form of SPL token staking derivatives. The administrator receives a fee in the form of SPL token staking derivatives. The manager
sets the fee on creation. Let's create a pool with a 3% fee: sets the fee on creation. Let's create a pool with a 3% fee and a maximum of 1000
validator stake accounts:
```sh ```sh
$ spl-stake-pool create-pool --fee-numerator 3 --fee-denominator 100 $ spl-stake-pool create-pool --fee-numerator 3 --fee-denominator 100 --max-validators 1000
Creating mint Gmk71cM7j2RMorRsQrsyysM4HsByQx5PuDGtDdqGLWCS Creating reserve stake 33Hg3bvYrAwfqCzTMjAWZNAWC6H96qJNEdzGamfFjG4J
Creating pool fee collection account 3xvXPfQi2SaTkqPV9A7BQwh4GyTe2ZPasfoaCBCnTAJ5 Creating mint D5yiK1tE1yAXBnrV9ZrSUJCw8WiQctZ8ekbv1U6ATVZ
Creating stake pool 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC Creating pool fee collection account 5gpuSdutGY98KKbgmR5CfLK7toFcQD69JzKDwseegzXE
Signature: 5HdDoPssqwyLjt2QvhRbnSATZqFLGKha92zMuJiBUpKeKYKGURRV41N5ydCQxqnFjCud3xv85Z6ghErppNJzaYM8 Signature: 2dvCtHMcqxibckhvVgFQeFCRb7VcHbuFLRf71Aqd9PtzFzdbG3gAkNpxYznfpKDx2vTRrVtwW81sZAx5U3Frb5Uu
Creating stake pool EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Signature: 2kYDVyJp8FVrLmEZyW9ivMYcXEsgWm4hFyhp5omxVtonjhYG6WS1S85sPTCdsQWe3idof6ZqsY8F3oaMXwrEkAYK
``` ```
The unique stake pool identifier is `3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC`. The unique stake pool identifier is `EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1`.
The identifier for the SPL token for staking derivatives is The identifier for the SPL token for staking derivatives is
`Gmk71cM7j2RMorRsQrsyysM4HsByQx5PuDGtDdqGLWCS`. The stake pool has full control `D5yiK1tE1yAXBnrV9ZrSUJCw8WiQctZ8ekbv1U6ATVZ`. The stake pool has full control
over the mint. over the mint.
The pool creator's fee account identifier is The pool creator's fee account identifier is
`3xvXPfQi2SaTkqPV9A7BQwh4GyTe2ZPasfoaCBCnTAJ5`. When users deposit warmed up `5gpuSdutGY98KKbgmR5CfLK7toFcQD69JzKDwseegzXE`. Every epoch, as stake accounts
stake accounts into the stake pool, the program will transfer 3% of their in the stake pool earn rewards, the program will mint SPL token staking derivatives
contribution into this account in the form of SPL token staking derivatives. equal to 3% of the gains on that epoch into this account. If no gains were observed,
nothing will be deposited.
The reserve stake account identifier is `33Hg3bvYrAwfqCzTMjAWZNAWC6H96qJNEdzGamfFjG4J`.
This account holds onto additional stake used when rebalancing between validators.
For a stake pool with 1000 validators, the cost to create a stake pool is less
than 0.5 SOL.
#### Set manager
The stake pool manager may pass their administrator privileges to another account.
```sh
$ spl-stake-pool set-manager EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 --new-manager 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Signature: 39N5gkaqXuWm6JPEUWfenKXeG4nSa71p7iHb9zurvdZcsWmbjdmSXwLVYfhAVHWucTY77sJ8SkUNpVpVAhe4eZ53
```
At the same time, they may also change the SPL token account that receives fees
every epoch. The mint for the provided token account must be the SPL token mint,
`D5yiK1tE1yAXBnrV9ZrSUJCw8WiQctZ8ekbv1U6ATVZ` in our example.
```sh
$ spl-stake-pool set-manager EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 --new-fee-receiver HoCsh97wRxRXVjtG7dyfsXSwH9VxdDzC7GvAsBE1eqJz
Signature: 4aK8yzYvPBkP4PyuXTcCm529kjEH6tTt4ixc5D5ZyCrHwc4pvxAHj6wcr4cpAE1e3LddE87J1GLD466aiifcXoAY
```
#### Set fee
The stake pool manager may update the fee assessed every epoch, passing the
numerator and denominator for the fraction that make up the fee. For a fee of
10%, they could run:
```sh
$ spl-stake-pool set-fee EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 10 100
Signature: 5yPXfVj5cbKBfZiEVi2UR5bXzVDuc2c3ruBwSjkAqpvxPHigwGHiS1mXQVE4qwok5moMWT5RNYAMvkE9bnfQ1i93
```
In order to protect stake pool depositors from malicious managers, the program
applies the new fee for the following epoch. For example, if the fee is 1% at
epoch 100, and the manager sets it to 10%, the manager will still gain 1% for
the rewards earned during epoch 100. Starting with epoch 101, the manager will
earn 10%.
#### Set staker
In order to manage the stake accounts, the stake pool manager or
staker can set the staker authority of the stake pool's managed accounts.
```sh
$ spl-stake-pool set-staker EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Signature: 39N5gkaqXuWm6JPEUWfenKXeG4nSa71p7iHb9zurvdZcsWmbjdmSXwLVYfhAVHWucTY77sJ8SkUNpVpVAhe4eZ53
```
Now, the new staker can perform any normal stake pool operations, including
adding and removing validators and rebalancing stake.
Important security note: the stake pool program only gives staking authority to
the pool staker and always retains withdraw authority. Therefore, a malicious
stake pool staker cannot steal funds from the stake pool.
Note: to avoid "disturbing the manager", the staker can also reassign their stake
authority.
### Stake Pool Staker Examples
#### Create a validator stake account #### Create a validator stake account
@ -170,7 +252,7 @@ lists, we choose some validators at random and start with identity
delegated to that vote account. delegated to that vote account.
```sh ```sh
$ spl-stake-pool create-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 $ spl-stake-pool create-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3
Creating stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Creating stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
Signature: 4pA2WKT6d2wkXEtSpiQswv22WyoFad2KX6FdPEzwBiEquvaUBEtzenys5Jh1ABPCh7yc4w8kzqMRRCwDj6ZSUV1K Signature: 4pA2WKT6d2wkXEtSpiQswv22WyoFad2KX6FdPEzwBiEquvaUBEtzenys5Jh1ABPCh7yc4w8kzqMRRCwDj6ZSUV1K
``` ```
@ -179,13 +261,13 @@ In order to maximize censorship resistance, we want to distribute our SOL to as
many validators as possible, so let's add a few more. many validators as possible, so let's add a few more.
```sh ```sh
$ spl-stake-pool create-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz $ spl-stake-pool create-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz
Creating stake account E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Creating stake account E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie
Signature: 4pyRZzjsWG7jP3GRZeZCo2Eb2TPjHM4kAYRFMivimme6HAee1nhzoNJBe3VSt2sv7acp5fwT7J8omBM8o3niY8gu Signature: 4pyRZzjsWG7jP3GRZeZCo2Eb2TPjHM4kAYRFMivimme6HAee1nhzoNJBe3VSt2sv7acp5fwT7J8omBM8o3niY8gu
$ spl-stake-pool create-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G $ spl-stake-pool create-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G
Creating stake account CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E Creating stake account CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E
Signature: 4ZUdZzUARgUCPuY8nVsJbN6vRDbVX8sYAQGYYXj2YVvjoJ2oevq2H8uzrhYApe419uoP7QYukqNstiti5p5DDukN Signature: 4ZUdZzUARgUCPuY8nVsJbN6vRDbVX8sYAQGYYXj2YVvjoJ2oevq2H8uzrhYApe419uoP7QYukqNstiti5p5DDukN
$ spl-stake-pool create-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm $ spl-stake-pool create-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm
Creating stake account FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Creating stake account FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13
Signature: yQqXCbuA66wQsHtkziNg3XadfZF5aCmvjfentwbZJnSPeEjJwPka3M1QY5GmR1efprptqaePn71BTMSLscX8DLr Signature: yQqXCbuA66wQsHtkziNg3XadfZF5aCmvjfentwbZJnSPeEjJwPka3M1QY5GmR1efprptqaePn71BTMSLscX8DLr
``` ```
@ -235,22 +317,21 @@ We created new validator stake accounts in the last step and staked them. Once
the stake activates, we can add them to the stake pool. the stake activates, we can add them to the stake pool.
```sh ```sh
$ spl-stake-pool add-validator 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN $ spl-stake-pool add-validator EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3
Creating account to receive tokens Gu8xqzYFg2sPHWHhUivKNBeF9uikiauihLs9hLzziKu7
Signature: 3N1K89rGV9gWueTTrPGTDBwKAp8BikQhKHMFoREw98Q1piXFeZSSxqfnRQexrfAZQfrpYH9qwsaPWRruwkVeBivV Signature: 3N1K89rGV9gWueTTrPGTDBwKAp8BikQhKHMFoREw98Q1piXFeZSSxqfnRQexrfAZQfrpYH9qwsaPWRruwkVeBivV
``` ```
Users can start depositing their activated stakes into the stake pool, as Users can start depositing their activated stakes into the stake pool, as
long as they are delegated to the same vote account, which was long as they are delegated to the same vote account, which was
`FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13` in this example. You can also `FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN` in this example. You can also
double-check that at any time using the Solana command-line utility. double-check that at any time using the Solana command-line utility.
```sh ```sh
$ solana stake-account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN $ solana stake-account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
Balance: 0.002282881 SOL Balance: 0.002282881 SOL
Rent Exempt Reserve: 0.00228288 SOL Rent Exempt Reserve: 0.00228288 SOL
Delegated Stake: 0.000000001 SOL Delegated Stake: 1.000000000 SOL
Active Stake: 0.000000001 SOL Active Stake: 1.000000000 SOL
Activating Stake: 0 SOL Activating Stake: 0 SOL
Stake activates starting from epoch: 161 Stake activates starting from epoch: 161
Delegated Vote Account Address: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 Delegated Vote Account Address: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3
@ -260,26 +341,31 @@ Withdraw Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
#### Remove validator stake account #### Remove validator stake account
If the stake pool manager wants to stop delegating to a vote account, they can If the stake pool staker wants to stop delegating to a vote account, they can
totally remove the validator stake account from the stake pool by providing totally remove the validator stake account from the stake pool.
staking derivatives, just like `withdraw`.
```sh ```sh
$ spl-stake-pool remove-validator 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF $ spl-stake-pool remove-validator EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G
Signature: 5rrQ3xhDWyiPkUTAQkNAeq31n6sMf1xsg2x9hVY8Vj1NonwBnhxuTv87nADLkwC8Xzc4CGTNCTX2Vph9esWnXk2d Signature: 5rrQ3xhDWyiPkUTAQkNAeq31n6sMf1xsg2x9hVY8Vj1NonwBnhxuTv87nADLkwC8Xzc4CGTNCTX2Vph9esWnXk2d
``` ```
The difference with `withdraw` is that the validator stake account is totally The difference with `withdraw` is that the validator stake account is totally
removed from the stake pool and now belongs to the administrator. removed from the stake pool and now belongs to the administrator. The authority
for the withdrawn stake account can also be specified using the `--new-authority` flag:
```sh
$ spl-stake-pool remove-validator EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G --new-authority 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Signature: 5rrQ3xhDWyiPkUTAQkNAeq31n6sMf1xsg2x9hVY8Vj1NonwBnhxuTv87nADLkwC8Xzc4CGTNCTX2Vph9esWnXk2d
```
We can check the removed stake account: We can check the removed stake account:
```sh ```sh
$ solana stake-account CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E $ solana stake-account CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E
Balance: 1.002282881 SOL Balance: 1.002282880 SOL
Rent Exempt Reserve: 0.00228288 SOL Rent Exempt Reserve: 0.00228288 SOL
Delegated Stake: 1.000000001 SOL Delegated Stake: 1.000000000 SOL
Active Stake: 1.000000001 SOL Active Stake: 1.000000000 SOL
Delegated Vote Account Address: AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G Delegated Vote Account Address: AUCzCaGAGjL3uyjFBtJs7KuJcgQWvNZu1Z2S9G3pw77G
Stake Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn Stake Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Withdraw Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn Withdraw Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
@ -291,7 +377,7 @@ removal of staked SOL from the pool.
We can also double-check that the stake pool no longer shows the stake account: We can also double-check that the stake pool no longer shows the stake account:
```sh ```sh
$ spl-stake-pool list 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool list EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎1.002282881 Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎1.002282881
Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎3.410872673 Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎3.410872673
Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎11.436803652 Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎11.436803652
@ -300,14 +386,14 @@ Total: ◎15.849959206
#### Rebalance the stake pool #### Rebalance the stake pool
As time goes on, deposits and withdrawals will happen to all of the stake accounts As time goes on, users will deposit to and withdraw from all of the stake accounts
managed by the pool, and the stake pool manager may want to rebalance the stakes. managed by the pool, and the stake pool staker may want to rebalance the stakes.
For example, let's say the manager wants the same delegation to every validator For example, let's say the staker wants the same delegation to every validator
in the pool. When they look at the state of the pool, they see: in the pool. When they look at the state of the pool, they see:
```sh ```sh
$ spl-stake-pool list 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool list EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎1.002282881 Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎1.002282881
Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎3.410872673 Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎3.410872673
Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎11.436803652 Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎11.436803652
@ -315,75 +401,63 @@ Total: ◎15.849959206
``` ```
This isn't great! The last stake account, `E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie` This isn't great! The last stake account, `E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie`
has too much allocated. For their strategy, the manager wants the `15.849959206` has too much allocated. For their strategy, the staker wants the `15.849959206`
SOL to be distributed evenly, meaning around `5.283319735` in each account. They need SOL to be distributed evenly, meaning around `5.283319735` in each account. They need
to move `4.281036854` to `FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13` and to move `4.281036854` to `FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13` and
`1.872447062` to `FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN`. `1.872447062` to `FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN`.
First, they need to withdraw a total of `6.153483916` from ##### Decrease validator stake
`E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie`. Using the `spl-token` utility,
let's check the total supply of pool tokens: First, they need to decrease the amount on stake account
`E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie`, delegated to
`HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz`, by total of `6.153483916` SOL.
They decrease that amount of SOL:
```sh ```sh
$ spl-token supply Gmk71cM7j2RMorRsQrsyysM4HsByQx5PuDGtDdqGLWCS $ spl-stake-pool decrease-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz 6.153483916
0.034692168 Signature: ZpQGwT85rJ8Y9afdkXhKo3TVv4xgTz741mmZj2vW7mihYseAkFsazWxza2y8eNGY4HDJm15c1cStwyiQzaM3RpH
``` ```
Given a total pool token supply of `0.034692168` and total staked SOL amount of Internally, this instruction splits and deactivates 6.153483916 SOL from the
`15.849959206`, let's calculate how many pool tokens to withdraw from the pool: validator stake account `E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie` into a
transient stake account, owned and managed entirely by the stake pool.
``` Once the stake is deactivated during the next epoch, the `update` command will
sol_to_withdraw * total_pool_tokens / total_sol_staked = pool_tokens_to_withdraw automatically merge the transient stake account into a reserve stake account,
6.153483916 * 0.034692168 / 15.849959206 ~ 0.013468659 also entirely owned and managed by the stake pool.
```
They withdraw that amount of pool tokens: ##### Increase validator stake
Now that the reserve stake account has enough to perform the rebalance, the staker
can increase the stake on the two other validators,
`8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm` and
`2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3`.
They add 4.281036854 SOL to `8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm`:
```sh ```sh
$ spl-stake-pool withdraw 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC --amount 0.013468659 --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF $ spl-stake-pool increase-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm 4.281036854
Withdrawing from account E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie, amount ◎6.153483855, 0.013468659 pool tokens Signature: 3GJACzjUGLPjcd9RLUW86AfBLWKapZRkxnEMc2yHT6erYtcKBgCapzyrVH6VN8Utxj7e2mtvzcigwLm6ZafXyTMw
Creating account to receive stake 8ykyY7maA9HUfUphZHBkhsnydY5gFfyHFSfxCA7imqrk
Signature: z8a5ZRfWdj8Fcsr3ttCJ731wFKyhZNcqoKEdV1RBCkzr3tHGQNCC56qvRVJ6oxyCVDqWZ3KL1Bkyn3sDpjYPDku
``` ```
Because of rounding in the calculation a few lines above, it looks like we receive And they add 1.872447062 SOL to `2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3`:
less than we should. If we play that back the other way, we'll see that all is well:
```
pool_tokens_to_withdraw * total_sol_staked / total_pool_tokens = sol_to_withdraw
0.013468659 * 15.849959206 / 0.034692168 ~ 6.153483855
```
Next, they deactivate the new received stake:
```sh ```sh
$ solana deactivate-stake 8ykyY7maA9HUfUphZHBkhsnydY5gFfyHFSfxCA7imqrk $ spl-stake-pool increase-validator-stake EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 1.872447062
Signature: 4SuwZK5JvYkYVkM5yfu2x8x6iou6558teMwzphGECLmstMVoWbSvngUH48Ra24PrxtgUDyVDA8SXYS1qMyx3fjMj Signature: 4zaKYu3MQ3as8reLbuHKaXN8FNaHvpHuiZtsJeARo67UKMo6wUUoWE88Fy8N4EYQYicuwULTNffcUD3a9jY88PoU
``` ```
Once the stake is deactivated during the next epoch, they split the stake Internally, this instruction also uses transient stake accounts. This time, the
and activate it on the other two validator vote accounts. For brevity, those stake pool splits from the reserve stake, into the transient stake account,
commands are omitted. then activates it to the appropriate validator.
Eventually, we are left with stake account `4zppED2kFodUS2hBf8Fzeepu6yZ6QuyeNPBXCT9VU6fK` One to two epochs later, once the transient stakes activate, the `update` command
with `4.281036854` delegated to `8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm` automatically merges the transient stakes into the validator stake account, leaving
and stake account `GCJnuFGCDzaToPwJtG5GiK4g3DJBfuhQy6388NyGcfwf` with `1.872447062` a fully rebalanced stake pool:
delegated to `2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3`.
Once the new stakes are ready, the manager deposits them back into the stake pool:
```sh
$ spl-stake-pool deposit 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC GCJnuFGCDzaToPwJtG5GiK4g3DJBfuhQy6388NyGcfwf --token-receiver 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
Depositing into stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
Signature: jKsdEr3zxF2zZs78rmrP3PmQiTwE7v15ieEuxp4db1VQe9owXVGM8nM3dJqVRHXPsS4frQW4gJ6xBfTTk2HvKDX
$ spl-stake-pool deposit 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC 4zppED2kFodUS2hBf8Fzeepu6yZ6QuyeNPBXCT9VU6fK --token-receiver 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
Depositing into stake account FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13
Signature: 3JXvTvea6F4Epd2krSxnTRZPB4gLZ8GqisFE58Z4ocV92fDN1HRMVPoPhJtYcfuF12vyQZUueKwVmkvL6Wgf2evc
```
Leaving them with a rebalanced stake pool!
```sh ```sh
$ spl-stake-pool list 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool list EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎5.283340235 Pubkey: FhFft7ArhZZkh6q4ir1JZMYFgXdH6wkT5M5nmDDb1Q13 Vote: 8r1f8mwrUiYdg2Rx9sxTh4M3UAUcCBBrmRA3nxk3Z6Lm ◎5.283340235
Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎5.283612231 Pubkey: FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Vote: 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3 ◎5.283612231
Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎5.284317422 Pubkey: E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie Vote: HJiC8iJ4Sj846SswQuauFJK93UvV6zp3c2T6jzGqzhhz ◎5.284317422
@ -391,33 +465,7 @@ Total: ◎15.851269888
``` ```
Due to staking rewards that accrued during the rebalancing process, the pool is Due to staking rewards that accrued during the rebalancing process, the pool is
not prefectly balanced. This is completely normal. not perfectly balanced. This is completely normal.
#### Set staking authority
In order to manage the stake accounts more directly, the stake pool owner can
set the stake authority of the stake pool's managed accounts.
```sh
$ spl-stake-pool set-staking-auth 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC --stake-account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN --new-staker 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Signature: 39N5gkaqXuWm6JPEUWfenKXeG4nSa71p7iHb9zurvdZcsWmbjdmSXwLVYfhAVHWucTY77sJ8SkUNpVpVAhe4eZ53
```
Now, the new staking authority can perform any normal staking operations,
including deactivating or re-staking.
Important security note: the stake pool program only gives staking authority to
the pool owner and always retains withdraw authority. Therefore, a malicious
stake pool manager cannot steal funds from the stake pool.
#### Set owner
The stake pool owner may pass their administrator privileges to another account.
```sh
$ spl-stake-pool 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC --new-owner 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Signature: 39N5gkaqXuWm6JPEUWfenKXeG4nSa71p7iHb9zurvdZcsWmbjdmSXwLVYfhAVHWucTY77sJ8SkUNpVpVAhe4eZ53
```
### User Examples ### User Examples
@ -429,7 +477,7 @@ command-line utility has a special instruction for finding out which vote
accounts are already associated with the stake pool. accounts are already associated with the stake pool.
```sh ```sh
$ spl-stake-pool list 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool list EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E 1.002282880 SOL CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E 1.002282880 SOL
E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie 1.002282880 SOL E5KBATUd21Dnjnh5sGFw5ngp9kdVXCcAAYMRe2WsVXie 1.002282880 SOL
FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN 1.002282880 SOL FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN 1.002282880 SOL
@ -441,13 +489,13 @@ If the manager has recently created the stake pool, and there are no stake
accounts present yet, the command-line utility will inform us. accounts present yet, the command-line utility will inform us.
```sh ```sh
$ spl-stake-pool list 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool list EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
No accounts found. No accounts found.
``` ```
#### Deposit stake #### Deposit stake
Stake pools only accept deposits from fully staked accounts, so we must first Stake pools only accept deposits from active accounts, so we must first
create stake accounts and delegate them to one of the validators managed by the create stake accounts and delegate them to one of the validators managed by the
stake pool. Using the `list` command from the previous section, we see that stake pool. Using the `list` command from the previous section, we see that
`2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3` is a valid vote account, so let's `2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3` is a valid vote account, so let's
@ -473,17 +521,19 @@ Two epochs later, when the stake is fully active and has received one epoch of
rewards, we can deposit the stake into the stake pool. rewards, we can deposit the stake into the stake pool.
```sh ```sh
$ spl-stake-pool deposit 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC 4F4AYKZbNtDnu7uQey2Vkz9VgkVtLE6XWLezYjc9yxZa $ spl-stake-pool deposit EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 4F4AYKZbNtDnu7uQey2Vkz9VgkVtLE6XWLezYjc9yxZa
Depositing into stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Depositing into stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
Creating account to receive tokens 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF Creating account to receive tokens 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
Signature: 4AESGZzqBVfj5xQnMiPWAwzJnAtQDRFK1Ha6jqKKTs46Zm5fw3LqgU1mRAT6CKTywVfFMHZCLm1hcQNScSMwVvjQ Signature: 4AESGZzqBVfj5xQnMiPWAwzJnAtQDRFK1Ha6jqKKTs46Zm5fw3LqgU1mRAT6CKTywVfFMHZCLm1hcQNScSMwVvjQ
``` ```
The CLI will default to using the fee payer's
[Associated Token Account](associated-token-account.md) for stake pool tokens.
Alternatively, you can create an SPL token account yourself and pass it as the Alternatively, you can create an SPL token account yourself and pass it as the
`token-receiver` for the command. `token-receiver` for the command.
```sh ```sh
$ spl-stake-pool deposit 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC 4F4AYKZbNtDnu7uQey2Vkz9VgkVtLE6XWLezYjc9yxZa --token-receiver 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF $ spl-stake-pool deposit EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 4F4AYKZbNtDnu7uQey2Vkz9VgkVtLE6XWLezYjc9yxZa --token-receiver 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
Depositing into stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN Depositing into stake account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
Signature: 4AESGZzqBVfj5xQnMiPWAwzJnAtQDRFK1Ha6jqKKTs46Zm5fw3LqgU1mRAT6CKTywVfFMHZCLm1hcQNScSMwVvjQ Signature: 4AESGZzqBVfj5xQnMiPWAwzJnAtQDRFK1Ha6jqKKTs46Zm5fw3LqgU1mRAT6CKTywVfFMHZCLm1hcQNScSMwVvjQ
``` ```
@ -505,7 +555,8 @@ In order to calculate the proper value of these stake pool tokens, we must updat
the total value managed by the stake pool every epoch. the total value managed by the stake pool every epoch.
```sh ```sh
$ spl-stake-pool update 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool update EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Updating stake pool...
Signature: 3Yx1RH3Afqj5ckX8YvPCRt1DudVP4HuRPkh1dBPvTM9GqGxcB9ZXHGZPADVSZiaqKi166fevMG232EWxrRWswPtt Signature: 3Yx1RH3Afqj5ckX8YvPCRt1DudVP4HuRPkh1dBPvTM9GqGxcB9ZXHGZPADVSZiaqKi166fevMG232EWxrRWswPtt
``` ```
@ -513,13 +564,33 @@ If another user already updated the stake pool balance for the current epoch, we
see a different output. see a different output.
```sh ```sh
$ spl-stake-pool update 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC $ spl-stake-pool update EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1
Stake pool balances are up to date, no update required. Update not required
``` ```
If no one updates the stake pool in the current epoch, the deposit and withdraw If no one updates the stake pool in the current epoch, the deposit and withdraw
instructions will fail. The update instruction is permissionless, so any user instructions will fail. The update instruction is permissionless, so any user
can run it before depositing or withdrawing. can run it before depositing or withdrawing. As a convenience, the CLI attempts
to update before running any instruction on the stake pool.
If the stake pool transient stakes are in an unexpected state, and merges are
not possible, there is the option to only update the stake pool balances without
performing merges using the `--no-merge` flag.
```sh
$ spl-stake-pool update EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 --no-merge
Updating stake pool...
Signature: 3Yx1RH3Afqj5ckX8YvPCRt1DudVP4HuRPkh1dBPvTM9GqGxcB9ZXHGZPADVSZiaqKi166fevMG232EWxrRWswPtt
```
Later on, whenever the transient stakes are ready to be merged, it is possible to
force another update in the same epoch using the `--force` flag.
```sh
$ spl-stake-pool update EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 --force
Updating stake pool...
Signature: 3Yx1RH3Afqj5ckX8YvPCRt1DudVP4HuRPkh1dBPvTM9GqGxcB9ZXHGZPADVSZiaqKi166fevMG232EWxrRWswPtt
```
#### Withdraw stake #### Withdraw stake
@ -529,7 +600,7 @@ staking derivative SPL tokens in exchange for an activated stake account.
Let's withdraw 0.02 staking derivative tokens from the stake pool. Let's withdraw 0.02 staking derivative tokens from the stake pool.
```sh ```sh
$ spl-stake-pool withdraw 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC --amount 0.02 --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF $ spl-stake-pool withdraw EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 0.02
Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens
Creating account to receive stake CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ Creating account to receive stake CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ
Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM
@ -550,15 +621,58 @@ Stake Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
Withdraw Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn Withdraw Authority: 4SnSuUtJGKvk2GYpBwmEsWG53zTurVM8yXGsoiZQyMJn
``` ```
Alternatively, the user can specify an existing stake account to receive their Alternatively, the user can specify an existing uninitialized stake account to
stake using the `stake-receiver` parameter. receive their stake using the `--stake-receiver` parameter.
```sh ```sh
$ spl-stake-pool withdraw 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC --amount 0.02 --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF --stake-receiver CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ $ spl-stake-pool withdraw EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 --amount 0.02 --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF --stake-receiver CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ
Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens
Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM
``` ```
By default, the withdraw command uses the fee payer's associated token account to
source the derivative tokens. It's possible to specify the SPL token account using
the `--pool-account` flag.
```sh
$ spl-stake-pool withdraw EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 0.02 --pool-account 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens
Creating account to receive stake CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ
Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM
```
By default, the withdraw command will withdraw from the largest validator stake
accounts in the pool. It's also possible to specify a specific vote account for
the withdraw using the `--vote-account` flag.
```sh
$ spl-stake-pool withdraw EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 0.02 --vote-account 2HUKQz7W2nXZSwrdX5RkfS2rLU4j1QZLjdGCHcoUKFh3
Withdrawing from account FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN, amount 8.867176377 SOL, 0.02 pool tokens
Creating account to receive stake CZF2z3JJoDmJRcVjtsrz1BKUUGNL3VPW5FPFqge1bzmQ
Signature: 2xBPVPJ749AE4hHNCNYdjuHv1EdMvxm9uvvraWfTA7Urrvecwh9w64URCyLLroLQ2RKDGE2QELM2ZHd8qRkjavJM
```
Note that the associated validator stake account must have enough lamports to
satisfy the pool token amount requested.
##### Special case: exiting pool with a delinquent staker
With the reserve stake, it's possible for a delinquent or malicious staker to
move all stake into the reserve through `decrease-validator-stake`, so the
staking derivatives will not gain rewards, and the stake pool users will not
be able to withdraw their funds.
To get around this case, it is also possible to withdraw from the stake pool's
reserve, but only if all of the validator stake accounts are at the minimum amount of
`1 SOL + stake account rent exemption`.
```sh
$ spl-stake-pool withdraw EjspffVUi2Tivszzs2JVj4GiSiMNYKyqZpgP3NeefBU1 0.02 --use-reserve
Withdrawing from account 33Hg3bvYrAwfqCzTMjAWZNAWC6H96qJNEdzGamfFjG4J, amount 8.867176377 SOL, 0.02 pool tokens
Creating account to receive stake 9E5YzXXu9NDhtMxWJKCwe2M8Sdz6vL6bcBS92U76PVtE
Signature: 4aZaeT9Azcq23PdKcjbQLseNveZVAQ4xMabBGQspfX316cE62Q2hoES373ExbT9y2JUhug7SgdybNaCjuZ6uqNYf
```
## Appendix ## Appendix
### Activated stakes ### Activated stakes
@ -569,6 +683,22 @@ are not equivalent to inactive, activating, or deactivating stakes due to the
time cost of staking. Otherwise, malicious actors can deposit stake in one state time cost of staking. Otherwise, malicious actors can deposit stake in one state
and withdraw it in another state without waiting. and withdraw it in another state without waiting.
### Transient stake accounts
Each validator gets one transient stake account, so the staker can only
perform one action at a time on a validator. It's impossible to increase
and decrease the stake on a validator at the same time. The staker must wait for
the existing transient stake account to get merged during an `update` instruction
before performing a new action.
### Reserve stake account
Every stake pool is initialized with an undelegated reserve stake account, used
to hold undelegated stake in process of rebalancing. After the staker decreases
the stake on a validator, one epoch later, the update operation will merge the
decreased stake into the reserve. Conversely, whenever the staker increases the
stake on a validator, the lamports are drawn from the reserve stake account.
### Staking Credits Observed on Deposit ### Staking Credits Observed on Deposit
A deposited stake account's "credits observed" must match the destination A deposited stake account's "credits observed" must match the destination

View File

@ -38,7 +38,7 @@ convention around wallet address to token account mapping and funding.
The `spl-token` command-line utility can be used to experiment with SPL The `spl-token` command-line utility can be used to experiment with SPL
tokens. Once you have [Rust installed](https://rustup.rs/), run: tokens. Once you have [Rust installed](https://rustup.rs/), run:
```sh ```console
$ cargo install spl-token-cli $ cargo install spl-token-cli
``` ```
@ -50,11 +50,8 @@ The `spl-token` configuration is shared with the `solana` command-line tool.
#### Current Configuration #### Current Configuration
``` ```console
solana config get $ solana config get
```
```
Config File: ${HOME}/.config/solana/cli/config.yml Config File: ${HOME}/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed) WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
@ -64,8 +61,8 @@ Keypair Path: ${HOME}/.config/solana/id.json
#### Cluster RPC URL #### Cluster RPC URL
See [Solana clusters](https://docs.solana.com/clusters) for cluster-specific RPC URLs See [Solana clusters](https://docs.solana.com/clusters) for cluster-specific RPC URLs
``` ```console
solana config set --url https://devnet.solana.com $ solana config set --url https://api.devnet.solana.com
``` ```
#### Default Keypair #### Default Keypair
@ -74,18 +71,27 @@ See [Keypair conventions](https://docs.solana.com/cli/conventions#keypair-conven
for information on how to setup a keypair if you don't already have one. for information on how to setup a keypair if you don't already have one.
Keypair File Keypair File
``` ```console
solana config set --keypair ${HOME}/new-keypair.json $ solana config set --keypair ${HOME}/new-keypair.json
``` ```
Hardware Wallet URL (See [URL spec](https://docs.solana.com/wallet-guide/hardware-wallets#specify-a-keypair-url)) Hardware Wallet URL (See [URL spec](https://docs.solana.com/wallet-guide/hardware-wallets#specify-a-keypair-url))
```console
$ solana config set --keypair usb://ledger/
``` ```
solana config set --keypair usb://ledger/
#### Airdrop SOL
Creating tokens and accounts requires SOL for account rent deposits and
transaction fees. If the cluster you are targeting offers a faucet, you can get
a little SOL for testing:
```console
$ solana airdrop 1
``` ```
### Example: Creating your own fungible token ### Example: Creating your own fungible token
```sh ```console
$ spl-token create-token $ spl-token create-token
Creating token AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM Creating token AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
Signature: 47hsLFxWRCg8azaZZPSnQR8DNTRsGyPNfUK7jqyzgt7wf9eag3nSnewqoZrVZHKm8zt3B6gzxhr91gdQ5qYrsRG4 Signature: 47hsLFxWRCg8azaZZPSnQR8DNTRsGyPNfUK7jqyzgt7wf9eag3nSnewqoZrVZHKm8zt3B6gzxhr91gdQ5qYrsRG4
@ -94,27 +100,27 @@ Signature: 47hsLFxWRCg8azaZZPSnQR8DNTRsGyPNfUK7jqyzgt7wf9eag3nSnewqoZrVZHKm8zt3B
The unique identifier of the token is `AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM`. The unique identifier of the token is `AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM`.
Tokens when initially created by `spl-token` have no supply: Tokens when initially created by `spl-token` have no supply:
```sh ```console
spl-token supply AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM $ spl-token supply AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
0 0
``` ```
Let's mint some. First create an account to hold a balance of the new Let's mint some. First create an account to hold a balance of the new
`AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM` token: `AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM` token:
```sh ```console
$ spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM $ spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
Creating account 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi Creating account 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi
Signature: 42Sa5eK9dMEQyvD9GMHuKxXf55WLZ7tfjabUKDhNoZRAxj9MsnN7omriWMEHXLea3aYpjZ862qocRLVikvkHkyfy Signature: 42Sa5eK9dMEQyvD9GMHuKxXf55WLZ7tfjabUKDhNoZRAxj9MsnN7omriWMEHXLea3aYpjZ862qocRLVikvkHkyfy
``` ```
`7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi` is now an empty account: `7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi` is now an empty account:
```sh ```console
$ spl-token balance 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi $ spl-token balance AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
0 0
``` ```
Mint 100 tokens into the account: Mint 100 tokens into the account:
```sh ```console
$ spl-token mint AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100 $ spl-token mint AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100
Minting 100 tokens Minting 100 tokens
Token: AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM Token: AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
@ -123,16 +129,19 @@ Signature: 41mARH42fPkbYn1mvQ6hYLjmJtjW98NXwd6pHqEYg9p8RnuoUsMxVd16RkStDHEzcS2sf
``` ```
The token `supply` and account `balance` now reflect the result of minting: The token `supply` and account `balance` now reflect the result of minting:
```sh ```console
$ spl-token supply AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM $ spl-token supply AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
100 100
$ spl-token balance 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi ```
```console
$ spl-token balance AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
100 100
``` ```
### Example: View all Tokens that you own ### Example: View all Tokens that you own
```sh ```console
$ spl-token accounts $ spl-token accounts
Token Balance Token Balance
------------------------------------------------------------ ------------------------------------------------------------
@ -144,14 +153,14 @@ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 1 (Aux-2*)
### Example: Wrapping SOL in a Token ### Example: Wrapping SOL in a Token
```sh ```console
$ spl-token wrap 1 $ spl-token wrap 1
Wrapping 1 SOL into GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje Wrapping 1 SOL into GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje
Signature: 4f4s5QVMKisLS6ihZcXXPbiBAzjnvkBcp2A7KKER7k9DwJ4qjbVsQBKv2rAyBumXC1gLn8EJQhwWkybE4yJGnw2Y Signature: 4f4s5QVMKisLS6ihZcXXPbiBAzjnvkBcp2A7KKER7k9DwJ4qjbVsQBKv2rAyBumXC1gLn8EJQhwWkybE4yJGnw2Y
``` ```
To unwrap the Token back to SOL: To unwrap the Token back to SOL:
``` ```console
$ spl-token unwrap GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje $ spl-token unwrap GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje
Unwrapping GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje Unwrapping GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje
Amount: 1 SOL Amount: 1 SOL
@ -165,8 +174,8 @@ token account for the Token type. Then the receiver obtains their wallet
address by running `solana address` and provides it to the sender. address by running `solana address` and provides it to the sender.
The sender then runs: The sender then runs:
``` ```console
$ spl-token transfer 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi 50 vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg $ spl-token transfer AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 50 vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
Transfer 50 tokens Transfer 50 tokens
Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi
Recipient: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg Recipient: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
@ -183,8 +192,8 @@ The receiver obtains their wallet address by running `solana address` and provid
The sender then runs to fund the receiver's associated token account, at the The sender then runs to fund the receiver's associated token account, at the
sender's expense, and then transfers 50 tokens into it: sender's expense, and then transfers 50 tokens into it:
``` ```console
$ spl-token transfer --fund-recipient 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi 50 vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg $ spl-token transfer --fund-recipient AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 50 vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
Transfer 50 tokens Transfer 50 tokens
Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi
Recipient: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg Recipient: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
@ -198,19 +207,21 @@ Signature: 5a3qbvoJQnTAxGPHCugibZTbSu7xuTgkxvF4EJupRjRXGgZZrnWFmKzfEzcqKF2ogCaF4
Tokens may be transferred to a specific recipient token account. The recipient Tokens may be transferred to a specific recipient token account. The recipient
token account must already exist and be of the same Token type. token account must already exist and be of the same Token type.
``` ```console
$ spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM $ spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM /path/to/auxiliary_keypair.json
Creating account CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ Creating account CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ
Signature: 4yPWj22mbyLu5mhfZ5WATNfYzTt5EQ7LGzryxM7Ufu7QCVjTE7czZdEBqdKR7vjKsfAqsBdjU58NJvXrTqCXvfWW Signature: 4yPWj22mbyLu5mhfZ5WATNfYzTt5EQ7LGzryxM7Ufu7QCVjTE7czZdEBqdKR7vjKsfAqsBdjU58NJvXrTqCXvfWW
``` ```
```
```console
$ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM -v $ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM -v
Account Token Balance Account Token Balance
-------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------
7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100
CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 0 (Aux-1*) CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 0 (Aux-1*)
``` ```
```
```console
$ spl-token transfer 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi 50 CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ $ spl-token transfer 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi 50 CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ
Transfer 50 tokens Transfer 50 tokens
Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi
@ -218,7 +229,8 @@ Transfer 50 tokens
Signature: 5a3qbvoJQnTAxGPHCugibZTbSu7xuTgkxvF4EJupRjRXGgZZrnWFmKzfEzcqKF2ogCaF4QKVbAtuFx7xGwrDUcGd Signature: 5a3qbvoJQnTAxGPHCugibZTbSu7xuTgkxvF4EJupRjRXGgZZrnWFmKzfEzcqKF2ogCaF4QKVbAtuFx7xGwrDUcGd
``` ```
```
```console
$ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM -v $ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM -v
Account Token Balance Account Token Balance
-------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------
@ -228,22 +240,22 @@ CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe
### Example: Create a non-fungible token ### Example: Create a non-fungible token
Create the token type, Create the token type with zero decimal place,
``` ```console
$ spl-token create-token $ spl-token create-token --decimals 0
Creating token 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z Creating token 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
Signature: 4kz82JUey1B9ki1McPW7NYv1NqPKCod6WNptSkYqtuiEsQb9exHaktSAHJJsm4YxuGNW4NugPJMFX9ee6WA2dXts Signature: 4kz82JUey1B9ki1McPW7NYv1NqPKCod6WNptSkYqtuiEsQb9exHaktSAHJJsm4YxuGNW4NugPJMFX9ee6WA2dXts
``` ```
then create an account to hold tokens of this new type: then create an account to hold tokens of this new type:
``` ```console
$ spl-token create-account 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z $ spl-token create-account 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
Creating account 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM Creating account 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM
Signature: sjChze6ecaRtvuQVZuwURyg6teYeiH8ZwT6UTuFNKjrdayQQ3KNdPB7d2DtUZ6McafBfEefejHkJ6MWQEfVHLtC Signature: sjChze6ecaRtvuQVZuwURyg6teYeiH8ZwT6UTuFNKjrdayQQ3KNdPB7d2DtUZ6McafBfEefejHkJ6MWQEfVHLtC
``` ```
Now mint only one token into the account, Now mint only one token into the account,
``` ```console
$ spl-token mint 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z 1 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM $ spl-token mint 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z 1 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM
Minting 1 tokens Minting 1 tokens
Token: 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z Token: 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
@ -252,7 +264,7 @@ Signature: 2Kzg6ZArQRCRvcoKSiievYy3sfPqGV91Whnz6SeimhJQXKBTYQf3E54tWg3zPpYLbcDex
``` ```
and disable future minting: and disable future minting:
``` ```console
$ spl-token authorize 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z mint --disable $ spl-token authorize 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z mint --disable
Updating 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z Updating 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
Current mint authority: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg Current mint authority: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
@ -263,8 +275,8 @@ Signature: 5QpykLzZsceoKcVRRFow9QCdae4Dp2zQAcjebyEWoezPFg2Np73gHKWQicHG1mqRdXu3y
Now the `7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM` account holds the Now the `7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM` account holds the
one and only `559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z` token: one and only `559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z` token:
``` ```console
$ spl-token account-info 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM $ spl-token account-info 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
Address: 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM Address: 7KqpRwzkkeweW5jQoETyLzhvs9rcCj9dVQ1MnzudirsM
Balance: 1 Balance: 1
@ -275,7 +287,7 @@ Delegation: (not set)
Close authority: (not set) Close authority: (not set)
``` ```
``` ```console
$ spl-token supply 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z $ spl-token supply 559u4Tdr9umKwft3yHMsnAxohhzkFnUBPAFtibwuZD9z
1 1
``` ```
@ -304,7 +316,7 @@ account.
First create keypairs to act as the multisig signer-set. In reality, these can First create keypairs to act as the multisig signer-set. In reality, these can
be any supported signer, like: a Ledger hardware wallet, a keypair file, or be any supported signer, like: a Ledger hardware wallet, a keypair file, or
a paper wallet. For convenience, keypair files will be used in this example. a paper wallet. For convenience, keypair files will be used in this example.
``` ```console
$ for i in $(seq 3); do solana-keygen new --no-passphrase -so "signer-${i}.json"; done $ for i in $(seq 3); do solana-keygen new --no-passphrase -so "signer-${i}.json"; done
Wrote new keypair to signer-1.json Wrote new keypair to signer-1.json
Wrote new keypair to signer-2.json Wrote new keypair to signer-2.json
@ -313,7 +325,7 @@ Wrote new keypair to signer-3.json
In order to create the multisig account, the public keys of the signer-set must In order to create the multisig account, the public keys of the signer-set must
be collected. be collected.
``` ```console
$ for i in $(seq 3); do SIGNER="signer-${i}.json"; echo "$SIGNER: $(solana-keygen pubkey "$SIGNER")"; done $ for i in $(seq 3); do SIGNER="signer-${i}.json"; echo "$SIGNER: $(solana-keygen pubkey "$SIGNER")"; done
signer-1.json: BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ signer-1.json: BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ
signer-2.json: DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY signer-2.json: DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY
@ -333,13 +345,15 @@ NOTE: SPL Token Multisig accounts are limited to a signer-set of eleven signers
``` ```
$ spl-token create-multisig 2 BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ \ $ spl-token create-multisig 2 BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ \
DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY D7ssXHrZJjfpZXsmDf8RwfPxe1BMMMmP1CtmX3WojPmG DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY D7ssXHrZJjfpZXsmDf8RwfPxe1BMMMmP1CtmX3WojPmG
```
```console
Creating 2/3 multisig 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re Creating 2/3 multisig 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re
Signature: 2FN4KXnczAz33SAxwsuevqrD1BvikP6LUhLie5Lz4ETt594X8R7yvMZzZW2zjmFLPsLQNHsRuhQeumExHbnUGC9A Signature: 2FN4KXnczAz33SAxwsuevqrD1BvikP6LUhLie5Lz4ETt594X8R7yvMZzZW2zjmFLPsLQNHsRuhQeumExHbnUGC9A
``` ```
Next create the token mint and receiving accounts Next create the token mint and receiving accounts
[as previously described](#example-creating-your-own-fungible-token) [as previously described](#example-creating-your-own-fungible-token)
``` ```console
$ spl-token create-token $ spl-token create-token
Creating token 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Creating token 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Signature: 3n6zmw3hS5Hyo5duuhnNvwjAbjzC42uzCA3TTsrgr9htUonzDUXdK1d8b8J77XoeSherqWQM8mD8E1TMYCpksS2r Signature: 3n6zmw3hS5Hyo5duuhnNvwjAbjzC42uzCA3TTsrgr9htUonzDUXdK1d8b8J77XoeSherqWQM8mD8E1TMYCpksS2r
@ -350,7 +364,7 @@ Signature: 5mVes7wjE7avuFqzrmSCWneKBQyPAjasCLYZPNSkmqmk2YFosYWAP9hYSiZ7b7NKpV866
``` ```
Then set the mint account's minting authority to the multisig account Then set the mint account's minting authority to the multisig account
``` ```console
$ spl-token authorize 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o mint 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re $ spl-token authorize 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o mint 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re
Updating 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Updating 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Current mint authority: 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE Current mint authority: 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE
@ -364,6 +378,8 @@ account, attempting to mint with one multisig signer fails
$ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \
--owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \ --owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \
--multisig-signer signer-1.json --multisig-signer signer-1.json
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
@ -372,28 +388,43 @@ RPC response error -32002: Transaction simulation failed: Error processing Instr
But repeating with a second multisig signer, succeeds But repeating with a second multisig signer, succeeds
``` ```
spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \
--owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \ --owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \
--multisig-signer signer-1.json \ --multisig-signer signer-1.json \
--multisig-signer signer-2.json --multisig-signer signer-2.json
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
Signature: 2ubqWqZb3ooDuc8FLaBkqZwzguhtMgQpgMAHhKsWcUzjy61qtJ7cZ1bfmYktKUfnbMYWTC1S8zdKgU6m4THsgspT Signature: 2ubqWqZb3ooDuc8FLaBkqZwzguhtMgQpgMAHhKsWcUzjy61qtJ7cZ1bfmYktKUfnbMYWTC1S8zdKgU6m4THsgspT
``` ```
### Example: Mint with multisig authority and offline signers ### Example: Offline signing with multisig
This example builds off of the [online mint with multisig](#example-mint-with-multisig-authority) Sometimes online signing is not possible or desireable. Such is the case for example when signers are not in the same geographic location
example. Be sure to familiarize yourself with that process, [offline signing](https://docs.solana.com/offline-signing), or when they use air-gapped devices not connected to the network. In this case, we use offline signing which combines the
and the [durable nonce](https://docs.solana.com/offline-signing/durable-nonce) previous examples of [multisig](#example-mint-with-multisig-authority) with [offline signing](https://docs.solana.com/offline-signing)
feature before continuing. and a [nonce account](https://docs.solana.com/offline-signing/durable-nonce).
This example will use the same mint account, token account, multisig account, This example will use the same mint account, token account, multisig account,
and multisig signer-set keypair filenames as the online example. and multisig signer-set keypair filenames as the online example, as well as a nonce
account that we create here:
A nonce account at `Fjyud2VXixk2vCs4DkBpfpsq48d81rbEzh6deKt7WvPj` will be used ```console
$ solana-keygen new -o nonce-keypair.json
...
======================================================================
pubkey: Fjyud2VXixk2vCs4DkBpfpsq48d81rbEzh6deKt7WvPj
======================================================================
``` ```
```console
$ solana create-nonce-account nonce-keypair.json 1
Signature: 3DALwrAAmCDxqeb4qXZ44WjpFcwVtgmJKhV4MW5qLJVtWeZ288j6Pzz1F4BmyPpnGLfx2P8MEJXmqPchX5y2Lf3r
```
```console
$ solana nonce-account Fjyud2VXixk2vCs4DkBpfpsq48d81rbEzh6deKt7WvPj $ solana nonce-account Fjyud2VXixk2vCs4DkBpfpsq48d81rbEzh6deKt7WvPj
Balance: 0.01 SOL Balance: 0.01 SOL
Minimum Balance Required: 0.00144768 SOL Minimum Balance Required: 0.00144768 SOL
@ -424,6 +455,9 @@ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd
--nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \ --nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \
--sign-only \ --sign-only \
--mint-decimals 9 --mint-decimals 9
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
@ -438,7 +472,7 @@ Absent Signers (Pubkey):
Next each offline signer executes the template command, replacing each instance Next each offline signer executes the template command, replacing each instance
of their public key with the corresponding keypair. of their public key with the corresponding keypair.
``` ```
spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC \
--owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \ --owner 46ed77fd4WTN144q62BwjU2B3ogX3Xmmc8PT5Z3Xc2re \
--multisig-signer signer-1.json \ --multisig-signer signer-1.json \
--multisig-signer DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY \ --multisig-signer DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY \
@ -448,6 +482,8 @@ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd4M
--nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \ --nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \
--sign-only \ --sign-only \
--mint-decimals 9 --mint-decimals 9
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
@ -471,6 +507,8 @@ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd
--nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \ --nonce-authority 5hbZyJ3KRuFvdy5QBxvE9KwK17hzkAUkQHZTxPbiWffE \
--sign-only \ --sign-only \
--mint-decimals 9 --mint-decimals 9
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
@ -503,6 +541,8 @@ $ spl-token mint 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o 1 EX8zyi2ZQUuoYtXd
--nonce-authority hot-wallet.json \ --nonce-authority hot-wallet.json \
--signer BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ=2QVah9XtvPAuhDB2QwE7gNaY962DhrGP6uy9zeN4sTWvY2xDUUzce6zkQeuT3xg44wsgtUw2H5Rf8pEArPSzJvHX \ --signer BzWpkuRrwXHq4SSSFHa8FJf6DRQy4TaeoXnkA89vTgHZ=2QVah9XtvPAuhDB2QwE7gNaY962DhrGP6uy9zeN4sTWvY2xDUUzce6zkQeuT3xg44wsgtUw2H5Rf8pEArPSzJvHX \
--signer DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY=2brZbTiCfyVYSCp6vZE3p7qCDeFf3z1JFmJHPBrz8SnWSDZPjbpjsW2kxFHkktTNkhES3y6UULqS4eaWztLW7FrU --signer DhkUfKgfZ8CF6PAGKwdABRL1VqkeNrTSRx8LZfpPFVNY=2brZbTiCfyVYSCp6vZE3p7qCDeFf3z1JFmJHPBrz8SnWSDZPjbpjsW2kxFHkktTNkhES3y6UULqS4eaWztLW7FrU
```
```console
Minting 1 tokens Minting 1 tokens
Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o Token: 4VNVRJetwapjwYU8jf4qPgaCeD76wyz8DuNj8yMCQ62o
Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC Recipient: EX8zyi2ZQUuoYtXd4MKmyHYLTjqFdWeuoTHcsTdJcKHC
@ -520,7 +560,7 @@ There is a rich set of JSON RPC methods available for use with SPL Token:
See https://docs.solana.com/apps/jsonrpc-api for more details. See https://docs.solana.com/apps/jsonrpc-api for more details.
Additionally the versatile `getProgramAcccounts` JSON RPC method can be employed in various ways to fetch SPL Token accounts of interest. Additionally the versatile `getProgramAccounts` JSON RPC method can be employed in various ways to fetch SPL Token accounts of interest.
### Finding all token accounts for a specific mint ### Finding all token accounts for a specific mint
@ -553,7 +593,7 @@ curl http://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/js
``` ```
The `"dataSize": 165` filter selects all [Token The `"dataSize": 165` filter selects all [Token
Acccount](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L86-L106)s, Account](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L86-L106)s,
and then the `"memcmp": ...` filter selects based on the and then the `"memcmp": ...` filter selects based on the
[mint](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L88) [mint](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L88)
address within each token account. address within each token account.
@ -588,7 +628,7 @@ curl http://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/js
``` ```
The `"dataSize": 165` filter selects all [Token The `"dataSize": 165` filter selects all [Token
Acccount](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L86-L106)s, Account](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L86-L106)s,
and then the `"memcmp": ...` filter selects based on the and then the `"memcmp": ...` filter selects based on the
[owner](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L90) [owner](https://github.com/solana-labs/solana-program-library/blob/08d9999f997a8bf38719679be9d572f119d0d960/token/program/src/state.rs#L90)
address within each token account. address within each token account.
@ -825,7 +865,13 @@ The sender's wallet must not require that the recipient's main wallet address
hold a balance before allowing the transfer. hold a balance before allowing the transfer.
### Registry for token details ### Registry for token details
At the moment Token Mint addresses need to be hard coded by each wallet. **Improving this situation is a work in progress.** At the moment there exist two solutions for Token Mint registries:
* hard coded addresses in the wallet or dapp
* [spl-token-registry](https://www.npmjs.com/package/@solana/spl-token-registry)
package, maintained at [https://github.com/solana-labs/token-list](https://github.com/solana-labs/token-list)
**A decentralized solution is in progress.**
### Garbage Collecting Ancillary Token Accounts ### Garbage Collecting Ancillary Token Accounts
Wallets should empty ancillary token accounts as quickly as practical by Wallets should empty ancillary token accounts as quickly as practical by
@ -852,3 +898,13 @@ the maximum allowed transaction size, remove those extra clean up instructions.
They can be cleaned up during the next send operation. They can be cleaned up during the next send operation.
The `spl-token gc` command provides an example implementation of this cleanup process. The `spl-token gc` command provides an example implementation of this cleanup process.
### Token Vesting Contract:
This program allows you to lock arbitrary SPL tokens and release the locked tokens with a determined unlock schedule. An `unlock schedule` is made of a `unix timestamp` and a token `amount`, when initializing a vesting contract, the creator can pass an array of `unlock schedule` with an arbitrary size giving the creator of the contract complete control of how the tokens unlock over time.
Unlocking works by pushing a permissionless crank on the contract that moves the tokens to the pre-specified address. The recipient address of a vesting contract can be modified by the owner of the current recipient key, meaning that vesting contract locked tokens can be traded.
- Code: [https://github.com/Bonfida/token-vesting](https://github.com/Bonfida/token-vesting)
- UI: [https://vesting.bonfida.com/#/](https://vesting.bonfida.com/#/)
- Audit: The audit was conducted by Kudelski, the report can be found [here](https://github.com/Bonfida/token-vesting/blob/master/audit/Bonfida_SecurityAssessment_Vesting_Final050521.pdf)

View File

@ -22,7 +22,7 @@ extern uint64_t do_invoke(SolParameters *params) {
const SolSignerSeeds signers_seeds[] = {{seeds, SOL_ARRAY_SIZE(seeds)}}; const SolSignerSeeds signers_seeds[] = {{seeds, SOL_ARRAY_SIZE(seeds)}};
SolPubkey expected_allocated_key; SolPubkey expected_allocated_key;
if (SUCCESS == sol_create_program_address(seeds, SOL_ARRAY_SIZE(seeds), if (SUCCESS != sol_create_program_address(seeds, SOL_ARRAY_SIZE(seeds),
params->program_id, params->program_id,
&expected_allocated_key)) { &expected_allocated_key)) {
return ERROR_INVALID_INSTRUCTION_DATA; return ERROR_INVALID_INSTRUCTION_DATA;
@ -31,8 +31,7 @@ extern uint64_t do_invoke(SolParameters *params) {
return ERROR_INVALID_ARGUMENT; return ERROR_INVALID_ARGUMENT;
} }
SolAccountMeta arguments[] = {{system_program_info->key, false, false}, SolAccountMeta arguments[] = {{allocated_info->key, true, true}};
{allocated_info->key, true, true}};
uint8_t data[4 + 8]; // Enough room for the Allocate instruction uint8_t data[4 + 8]; // Enough room for the Allocate instruction
*(uint16_t *)data = 8; // Allocate instruction enum value *(uint16_t *)data = 8; // Allocate instruction enum value
*(uint64_t *)(data + 4) = SIZE; // Size to allocate *(uint64_t *)(data + 4) = SIZE; // Size to allocate

View File

@ -1,4 +1,3 @@
# Program examples written in Rust # Program examples written in Rust
The examples in this directory demonstrate various Solana program mechanisms. The examples in this directory demonstrate various Solana program mechanisms.

View File

@ -13,11 +13,11 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.3"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.3"
solana-sdk = "1.6.2" solana-sdk = "1.7.3"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -15,11 +15,11 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.3"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.3"
solana-sdk = "1.6.2" solana-sdk = "1.7.3"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -8,7 +8,7 @@ use {
#[tokio::test] #[tokio::test]
async fn test_custom_heap() { async fn test_custom_heap() {
let program_id = Pubkey::from_str(&"CustomHeap111111111111111111111111111111111").unwrap(); let program_id = Pubkey::from_str("CustomHeap111111111111111111111111111111111").unwrap();
let (mut banks_client, payer, recent_blockhash) = ProgramTest::new( let (mut banks_client, payer, recent_blockhash) = ProgramTest::new(
"spl_example_custom_heap", "spl_example_custom_heap",
program_id, program_id,

View File

@ -13,11 +13,11 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.3"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.3"
solana-sdk = "1.6.2" solana-sdk = "1.7.3"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -11,7 +11,7 @@ use {
#[tokio::test] #[tokio::test]
async fn test_logging() { async fn test_logging() {
let program_id = Pubkey::from_str(&"Logging111111111111111111111111111111111111").unwrap(); let program_id = Pubkey::from_str("Logging111111111111111111111111111111111111").unwrap();
let (mut banks_client, payer, recent_blockhash) = ProgramTest::new( let (mut banks_client, payer, recent_blockhash) = ProgramTest::new(
"spl_example_logging", "spl_example_logging",
program_id, program_id,

View File

@ -13,11 +13,11 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.3"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.3"
solana-sdk = "1.6.2" solana-sdk = "1.7.3"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -17,24 +17,28 @@ pub fn process_instruction(
// Create in iterator to safety reference accounts in the slice // Create in iterator to safety reference accounts in the slice
let account_info_iter = &mut accounts.iter(); let account_info_iter = &mut accounts.iter();
// The first account is the clock sysvar // Get the clock sysvar via syscall
let clock_via_sysvar = Clock::get()?;
// Or deserialize the account into a clock struct
let clock_sysvar_info = next_account_info(account_info_iter)?; let clock_sysvar_info = next_account_info(account_info_iter)?;
// The second account is the rent sysvar let clock_via_account = Clock::from_account_info(clock_sysvar_info)?;
let rent_sysvar_info = next_account_info(account_info_iter)?; // Both produce the same sysvar
assert_eq!(clock_via_sysvar, clock_via_account);
// Deserialize the account into a clock struct
let clock = Clock::from_account_info(&clock_sysvar_info)?;
// Deserialize the account into a rent struct
let rent = Rent::from_account_info(&rent_sysvar_info)?;
// Note: `format!` can be very expensive, use cautiously // Note: `format!` can be very expensive, use cautiously
msg!("{:?}", clock); msg!("{:?}", clock_via_sysvar);
// Get the rent sysvar via syscall
let rent_via_sysvar = Rent::get()?;
// Or deserialize the account into a rent struct
let rent_sysvar_info = next_account_info(account_info_iter)?;
let rent_via_account = Rent::from_account_info(rent_sysvar_info)?;
// Both produce the same sysvar
assert_eq!(rent_via_sysvar, rent_via_account);
// Can't print `exemption_threshold` because BPF does not support printing floats // Can't print `exemption_threshold` because BPF does not support printing floats
msg!( msg!(
"Rent: lamports_per_byte_year: {:?}, burn_percent: {:?}", "Rent: lamports_per_byte_year: {:?}, burn_percent: {:?}",
rent.lamports_per_byte_year, rent_via_sysvar.lamports_per_byte_year,
rent.burn_percent rent_via_sysvar.burn_percent
); );
Ok(()) Ok(())

View File

@ -12,7 +12,7 @@ use {
#[tokio::test] #[tokio::test]
async fn test_sysvar() { async fn test_sysvar() {
let program_id = Pubkey::from_str(&"Sysvar1111111111111111111111111111111111111").unwrap(); let program_id = Pubkey::from_str("Sysvar1111111111111111111111111111111111111").unwrap();
let (mut banks_client, payer, recent_blockhash) = ProgramTest::new( let (mut banks_client, payer, recent_blockhash) = ProgramTest::new(
"spl_example_sysvar", "spl_example_sysvar",
program_id, program_id,

View File

@ -12,11 +12,11 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
solana-program = "1.6.2" solana-program = "1.7.3"
[dev-dependencies] [dev-dependencies]
solana-program-test = "1.6.2" solana-program-test = "1.7.3"
solana-sdk = "1.6.2" solana-sdk = "1.7.3"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -11,7 +11,7 @@ use {
#[tokio::test] #[tokio::test]
async fn test_lamport_transfer() { async fn test_lamport_transfer() {
let program_id = Pubkey::from_str(&"TransferLamports111111111111111111111111111").unwrap(); let program_id = Pubkey::from_str("TransferLamports111111111111111111111111111").unwrap();
let source_pubkey = Pubkey::new_unique(); let source_pubkey = Pubkey::new_unique();
let destination_pubkey = Pubkey::new_unique(); let destination_pubkey = Pubkey::new_unique();
let mut program_test = ProgramTest::new( let mut program_test = ProgramTest::new(

View File

@ -10,11 +10,11 @@ edition = "2018"
[dependencies] [dependencies]
chrono = "0.4.19" chrono = "0.4.19"
clap = "2.33.3" clap = "2.33.3"
solana-clap-utils = "1.6.2" solana-clap-utils = "1.7.4"
solana-cli-config = "1.6.2" solana-cli-config = "1.7.4"
solana-client = "1.6.2" solana-client = "1.7.4"
solana-logger = "1.6.2" solana-logger = "1.7.4"
solana-sdk = "1.6.2" solana-sdk = "1.7.4"
spl-feature-proposal = { version = "1.0", path = "../program", features = ["no-entrypoint"] } spl-feature-proposal = { version = "1.0", path = "../program", features = ["no-entrypoint"] }
[[bin]] [[bin]]

View File

@ -46,7 +46,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.global(true) .global(true)
.help("Configuration file to use"); .help("Configuration file to use");
if let Some(ref config_file) = *solana_cli_config::CONFIG_FILE { if let Some(ref config_file) = *solana_cli_config::CONFIG_FILE {
arg.default_value(&config_file) arg.default_value(config_file)
} else { } else {
arg arg
} }
@ -329,7 +329,7 @@ fn process_propose(
Some(&config.keypair.pubkey()), Some(&config.keypair.pubkey()),
); );
let blockhash = rpc_client.get_recent_blockhash()?.0; let blockhash = rpc_client.get_recent_blockhash()?.0;
transaction.try_sign(&[&config.keypair, &feature_proposal_keypair], blockhash)?; transaction.try_sign(&[&config.keypair, feature_proposal_keypair], blockhash)?;
println!("JSON RPC URL: {}", config.json_rpc_url); println!("JSON RPC URL: {}", config.json_rpc_url);
@ -399,10 +399,9 @@ fn process_tally(
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let feature_proposal = get_feature_proposal(rpc_client, feature_proposal_address)?; let feature_proposal = get_feature_proposal(rpc_client, feature_proposal_address)?;
let feature_id_address = let feature_id_address = spl_feature_proposal::get_feature_id_address(feature_proposal_address);
spl_feature_proposal::get_feature_id_address(&feature_proposal_address);
let acceptance_token_address = let acceptance_token_address =
spl_feature_proposal::get_acceptance_token_address(&feature_proposal_address); spl_feature_proposal::get_acceptance_token_address(feature_proposal_address);
println!("Feature Id: {}", feature_id_address); println!("Feature Id: {}", feature_id_address);
println!("Acceptance Token Address: {}", acceptance_token_address); println!("Acceptance Token Address: {}", acceptance_token_address);

View File

@ -12,15 +12,14 @@ no-entrypoint = []
test-bpf = [] test-bpf = []
[dependencies] [dependencies]
borsh = "0.7.1" borsh = "0.9"
borsh-derive = "0.8.1" borsh-derive = "0.9.0"
solana-program = "1.6.2" solana-program = "1.7.4"
spl-token = { version = "3.1", path = "../../token/program", features = ["no-entrypoint"] } spl-token = { version = "3.1", path = "../../token/program", features = ["no-entrypoint"] }
[dev-dependencies] [dev-dependencies]
futures = "0.3" solana-program-test = "1.7.4"
solana-program-test = "1.6.2" solana-sdk = "1.7.4"
solana-sdk = "1.6.2"
[lib] [lib]
crate-type = ["cdylib", "lib"] crate-type = ["cdylib", "lib"]

View File

@ -155,13 +155,12 @@ pub fn tally(feature_proposal_address: &Pubkey) -> Instruction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::borsh_utils;
#[test] #[test]
fn test_get_packed_len() { fn test_get_packed_len() {
assert_eq!( assert_eq!(
FeatureProposalInstruction::get_packed_len(), FeatureProposalInstruction::get_packed_len(),
borsh_utils::get_packed_len::<FeatureProposalInstruction>() solana_program::borsh::get_packed_len::<FeatureProposalInstruction>()
) )
} }

View File

@ -2,7 +2,6 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
pub mod borsh_utils;
mod entrypoint; mod entrypoint;
pub mod instruction; pub mod instruction;
pub mod processor; pub mod processor;

View File

@ -126,7 +126,7 @@ pub fn process_instruction(
mint_info.clone(), mint_info.clone(),
system_program_info.clone(), system_program_info.clone(),
], ],
&[&mint_signer_seeds], &[mint_signer_seeds],
)?; )?;
msg!("Initializing mint"); msg!("Initializing mint");
@ -159,7 +159,7 @@ pub fn process_instruction(
distributor_token_info.clone(), distributor_token_info.clone(),
system_program_info.clone(), system_program_info.clone(),
], ],
&[&distributor_token_signer_seeds], &[distributor_token_signer_seeds],
)?; )?;
msg!("Initializing distributor token account"); msg!("Initializing distributor token account");
@ -193,7 +193,7 @@ pub fn process_instruction(
acceptance_token_info.clone(), acceptance_token_info.clone(),
system_program_info.clone(), system_program_info.clone(),
], ],
&[&acceptance_token_signer_seeds], &[acceptance_token_signer_seeds],
)?; )?;
msg!("Initializing acceptance token account"); msg!("Initializing acceptance token account");
@ -216,7 +216,7 @@ pub fn process_instruction(
&spl_token::instruction::set_authority( &spl_token::instruction::set_authority(
&spl_token::id(), &spl_token::id(),
acceptance_token_info.key, acceptance_token_info.key,
Some(&feature_proposal_info.key), Some(feature_proposal_info.key),
spl_token::instruction::AuthorityType::CloseAccount, spl_token::instruction::AuthorityType::CloseAccount,
feature_proposal_info.key, feature_proposal_info.key,
&[], &[],
@ -231,7 +231,7 @@ pub fn process_instruction(
&spl_token::instruction::set_authority( &spl_token::instruction::set_authority(
&spl_token::id(), &spl_token::id(),
acceptance_token_info.key, acceptance_token_info.key,
Some(&program_id), Some(program_id),
spl_token::instruction::AuthorityType::AccountOwner, spl_token::instruction::AuthorityType::AccountOwner,
feature_proposal_info.key, feature_proposal_info.key,
&[], &[],
@ -260,7 +260,7 @@ pub fn process_instruction(
distributor_token_info.clone(), distributor_token_info.clone(),
spl_token_program_info.clone(), spl_token_program_info.clone(),
], ],
&[&mint_signer_seeds], &[mint_signer_seeds],
)?; )?;
// Fully fund the feature id account so the `Tally` instruction will not require any // Fully fund the feature id account so the `Tally` instruction will not require any
@ -283,7 +283,7 @@ pub fn process_instruction(
invoke_signed( invoke_signed(
&system_instruction::allocate(feature_id_info.key, Feature::size_of() as u64), &system_instruction::allocate(feature_id_info.key, Feature::size_of() as u64),
&[feature_id_info.clone(), system_program_info.clone()], &[feature_id_info.clone(), system_program_info.clone()],
&[&feature_id_signer_seeds], &[feature_id_signer_seeds],
)?; )?;
} }
@ -348,7 +348,7 @@ pub fn process_instruction(
invoke_signed( invoke_signed(
&system_instruction::assign(feature_id_info.key, &feature::id()), &system_instruction::assign(feature_id_info.key, &feature::id()),
&[feature_id_info.clone(), system_program_info.clone()], &[feature_id_info.clone(), system_program_info.clone()],
&[&feature_id_signer_seeds], &[feature_id_signer_seeds],
)?; )?;
msg!("Feature proposal accepted"); msg!("Feature proposal accepted");

View File

@ -59,13 +59,12 @@ impl Pack for FeatureProposal {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::borsh_utils;
#[test] #[test]
fn test_get_packed_len() { fn test_get_packed_len() {
assert_eq!( assert_eq!(
FeatureProposal::get_packed_len(), FeatureProposal::get_packed_len(),
borsh_utils::get_packed_len::<FeatureProposal>() solana_program::borsh::get_packed_len::<FeatureProposal>()
); );
} }

View File

@ -1,21 +1,20 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program // Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
#![cfg(feature = "test-bpf")] #![cfg(feature = "test-bpf")]
use futures::{Future, FutureExt}; use {
use solana_program::{ solana_program::{
feature::{self, Feature}, feature::{self, Feature},
program_option::COption, program_option::COption,
program_pack::Pack,
pubkey::Pubkey, pubkey::Pubkey,
system_program, system_program,
}; },
use solana_program_test::*; solana_program_test::*,
use solana_sdk::{ solana_sdk::{
signature::{Keypair, Signer}, signature::{Keypair, Signer},
transaction::Transaction, transaction::Transaction,
},
spl_feature_proposal::{instruction::*, state::*, *},
}; };
use spl_feature_proposal::{instruction::*, state::*, *};
use std::io;
fn program_test() -> ProgramTest { fn program_test() -> ProgramTest {
ProgramTest::new( ProgramTest::new(
@ -25,21 +24,6 @@ fn program_test() -> ProgramTest {
) )
} }
/// Fetch and unpack account data
fn get_account_data<T: Pack>(
banks_client: &mut BanksClient,
address: Pubkey,
) -> impl Future<Output = std::io::Result<T>> + '_ {
banks_client.get_account(address).map(|result| {
let account =
result?.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "account not found"))?;
T::unpack_from_slice(&account.data)
.ok()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Failed to deserialize account"))
})
}
#[tokio::test] #[tokio::test]
async fn test_basic() { async fn test_basic() {
let feature_proposal = Keypair::new(); let feature_proposal = Keypair::new();
@ -68,16 +52,17 @@ async fn test_basic() {
banks_client.process_transaction(transaction).await.unwrap(); banks_client.process_transaction(transaction).await.unwrap();
// Confirm feature id account is now funded and allocated, but not assigned // Confirm feature id account is now funded and allocated, but not assigned
let feature_id_acccount = banks_client let feature_id_account = banks_client
.get_account(feature_id_address) .get_account(feature_id_address)
.await .await
.expect("success") .expect("success")
.expect("some account"); .expect("some account");
assert_eq!(feature_id_acccount.owner, system_program::id()); assert_eq!(feature_id_account.owner, system_program::id());
assert_eq!(feature_id_acccount.data.len(), Feature::size_of()); assert_eq!(feature_id_account.data.len(), Feature::size_of());
// Confirm mint account state // Confirm mint account state
let mint = get_account_data::<spl_token::state::Mint>(&mut banks_client, mint_address) let mint = banks_client
.get_packed_account_data::<spl_token::state::Mint>(mint_address)
.await .await
.unwrap(); .unwrap();
assert_eq!(mint.supply, 42); assert_eq!(mint.supply, 42);
@ -86,8 +71,8 @@ async fn test_basic() {
assert_eq!(mint.mint_authority, COption::Some(mint_address)); assert_eq!(mint.mint_authority, COption::Some(mint_address));
// Confirm distributor token account state // Confirm distributor token account state
let distributor_token = let distributor_token = banks_client
get_account_data::<spl_token::state::Account>(&mut banks_client, distributor_token_address) .get_packed_account_data::<spl_token::state::Account>(distributor_token_address)
.await .await
.unwrap(); .unwrap();
assert_eq!(distributor_token.amount, 42); assert_eq!(distributor_token.amount, 42);
@ -96,8 +81,8 @@ async fn test_basic() {
assert!(distributor_token.close_authority.is_none()); assert!(distributor_token.close_authority.is_none());
// Confirm acceptance token account state // Confirm acceptance token account state
let acceptance_token = let acceptance_token = banks_client
get_account_data::<spl_token::state::Account>(&mut banks_client, acceptance_token_address) .get_packed_account_data::<spl_token::state::Account>(acceptance_token_address)
.await .await
.unwrap(); .unwrap();
assert_eq!(acceptance_token.amount, 0); assert_eq!(acceptance_token.amount, 0);
@ -115,15 +100,17 @@ async fn test_basic() {
banks_client.process_transaction(transaction).await.unwrap(); banks_client.process_transaction(transaction).await.unwrap();
// Confirm feature id account is not yet assigned // Confirm feature id account is not yet assigned
let feature_id_acccount = banks_client let feature_id_account = banks_client
.get_account(feature_id_address) .get_account(feature_id_address)
.await .await
.expect("success") .expect("success")
.expect("some account"); .expect("some account");
assert_eq!(feature_id_acccount.owner, system_program::id()); assert_eq!(feature_id_account.owner, system_program::id());
assert!(matches!( assert!(matches!(
get_account_data::<FeatureProposal>(&mut banks_client, feature_proposal.pubkey()).await, banks_client
.get_packed_account_data::<FeatureProposal>(feature_proposal.pubkey())
.await,
Ok(FeatureProposal::Pending(_)) Ok(FeatureProposal::Pending(_))
)); ));
@ -158,16 +145,18 @@ async fn test_basic() {
banks_client.process_transaction(transaction).await.unwrap(); banks_client.process_transaction(transaction).await.unwrap();
// Confirm feature id account is now assigned // Confirm feature id account is now assigned
let feature_id_acccount = banks_client let feature_id_account = banks_client
.get_account(feature_id_address) .get_account(feature_id_address)
.await .await
.expect("success") .expect("success")
.expect("some account"); .expect("some account");
assert_eq!(feature_id_acccount.owner, feature::id()); assert_eq!(feature_id_account.owner, feature::id());
// Confirm feature proposal account state // Confirm feature proposal account state
assert!(matches!( assert!(matches!(
get_account_data::<FeatureProposal>(&mut banks_client, feature_proposal.pubkey()).await, banks_client
.get_packed_account_data::<FeatureProposal>(feature_proposal.pubkey())
.await,
Ok(FeatureProposal::Accepted { Ok(FeatureProposal::Accepted {
tokens_upon_acceptance: 42 tokens_upon_acceptance: 42
}) })
@ -197,7 +186,9 @@ async fn test_expired() {
banks_client.process_transaction(transaction).await.unwrap(); banks_client.process_transaction(transaction).await.unwrap();
assert!(matches!( assert!(matches!(
get_account_data::<FeatureProposal>(&mut banks_client, feature_proposal.pubkey()).await, banks_client
.get_packed_account_data::<FeatureProposal>(feature_proposal.pubkey())
.await,
Ok(FeatureProposal::Pending(_)) Ok(FeatureProposal::Pending(_))
)); ));
@ -208,7 +199,9 @@ async fn test_expired() {
banks_client.process_transaction(transaction).await.unwrap(); banks_client.process_transaction(transaction).await.unwrap();
assert!(matches!( assert!(matches!(
get_account_data::<FeatureProposal>(&mut banks_client, feature_proposal.pubkey()).await, banks_client
.get_packed_account_data::<FeatureProposal>(feature_proposal.pubkey())
.await,
Ok(FeatureProposal::Expired) Ok(FeatureProposal::Expired)
)); ));
} }

117
governance/README.md Normal file
View File

@ -0,0 +1,117 @@
# Governance
Governance is a program the chief purpose of which is to control the upgrade of other programs through democratic means.
It can also be used as an authority provider for mints and other forms of access control as well where we may want
a voting population to vote on disbursement of access or funds collectively.
## Architecture
### Accounts diagram (Program Governance use case)
![Accounts diagram](./resources/governance-accounts.jpg)
### Realm account
Realm account ties Community Token Mint and optional Council Token mint to create a realm
for any governance pertaining to the community of the token holders.
For example a trading protocol can issue a governance token and use it to create its governance realm.
Once a realm is created voters can deposit Governing tokens (Community or Council) to the realm and
use the deposited amount as their voting weight to vote on Proposals within that realm.
### Program Governance account
The basic building block of governance to update programs is the ProgramGovernance account.
It ties a governed Program ID and holds configuration options defining governance rules.
The governed Program ID is used as the seed for a [Program Derived Address](https://docs.solana.com/developing/programming-model/calling-between-programs#program-derived-addresses),
and this program derived address is what is used as the address of the Governance account for your Program ID.
What this means is that there can only ever be ONE Governance account for a given Program.
The governance program validates at creation time of the Governance account that the current upgrade authority of the program
taken under governance signed the transaction. Optionally `CreateProgramGovernance` instruction can also transfer `upgrade_authority`
of the governed program to the Governance PDA at the creation time of the Governance account.
### Mint Governance account
A mint governance account allows a mint authority to setup governance over an SPL Mint account.
The Governance program validates at creation time that the current mint authority signed the transaction to
create the governance and optionally can transfer the authority to the Governance account.
Once setup the Mint Governance allows governance participants to create Proposals which execute mint instructions for
the governed Mint.
### Token Governance account
A token governance account allows a token account owner to setup governance over an SPL Token account.
The Governance program validates at creation time the current owner signed the transaction to
create the governance and optionally can transfer the owner to the Governance account.
Once setup the Token Governance allows participants to create Proposals to execute transfer instructions
from the governed token account.
### How does the authority work?
Governance can handle arbitrary executions of code, but it's real power lies in the power to upgrade programs.
It does this through executing instructions to the bpf-upgradable-loader program.
Bpf-upgradable-loader allows any signer who has Upgrade authority over a Buffer account and the Program account itself
to upgrade it using its Upgrade command.
Normally, this is the developer who created and deployed the program, and this creation of the Buffer account containing
the new program data and overwriting of the existing Program account's data with it is handled in the background for you
by the Solana program deploy cli command.
However, in order for Governance to be useful, Governance now needs this authority.
In similar fashion for Mint and Token governances the relevant authorities to mint and transfer tokens
are transferred to the Governance account. It in turn allows participants to create and vote on Proposals
which can then execute
mint and transfer instructions for the governed accounts.
### Proposal accounts
A Proposal is an instance of a Governance created to vote on and execute given set of changes.
It is created by someone (Proposal Owner) and tied to a given Governance account
and has a set of executable instructions to it, a name and a description.
It goes through various states (draft, voting, executing, ...) and users can vote on it
if they have relevant Community or Council tokens.
Its rules are determined by the Governance account that it is tied to, and when it executes,
it is only eligible to use the [Program Derived Address](https://docs.solana.com/developing/programming-model/calling-between-programs#program-derived-addresses)
authority given by the Governance account.
So a Proposal for Sushi cannot for instance upgrade the Program for Uniswap.
When a Proposal is created by a user then the user becomes Proposal Owner and receives permission to edit the Proposal.
With this power the Owner can edit the Proposal, add/remove Signatories to the Proposal and also cancel it.
These Signatories can then show their approval of the Proposal by signing it off.
Once all Signatories have signed off the Proposal the Proposal leaves Draft state and enters Voting state.
Voting state lasts as long as the Governance has it configured to last, and during this time
people holding Community (or Council) tokens may vote on the Proposal.
Once the Proposal is "tipped" it either enters the Defeated or Succeeded state. If the vote can't be tipped automatically
during the voting period but still reaches the required Yes vote threshold it can be manually transitioned to Succeeded state
using FinalizeVote instruction.
Once all Proposal instructions are executed the Proposal enters Completed state.
In the Executing state an instruction can be run by any one at any time after the `instruction_hold_up_time` period has
transpired.
### ProposalInstruction
A Proposal can have multiple Proposal Instructions, and they run independently of each other.
These contain the actual data for an instruction, and how long after the voting phase a user must wait before they can
be executed.
### Voting Dynamics
When a Proposal is created and signed by its Signatories voters can start voting on it using their voting weight,
equal to deposited governing tokens into the realm. A vote is tipped once it passes the defined `vote_threshold` of votes
and enters Succeeded or Defeated state. If Succeeded then Proposal instructions can be executed after they hold_up_time passes.
Users can relinquish their vote any time during Proposal lifetime, but once Proposal it decided their vote can't be changed.
### Community and Councils governing tokens
Each Governance Realm that gets created has the option to also have a Council mint.
A council mint is simply a separate mint from the Community mint.
What this means is that users can submit Proposals that have a different voting population from a different mint
that can affect the same program. A practical application of this policy may be to have a very large population control
major version bumps of Solana via normal SOL, for instance, but hot fixes be controlled via Council tokens,
of which there may be only 30, and which may be themselves minted and distributed via proposals by the governing population.
### Proposal Workflow
![Proposal Workflow](./resources/governance-workflow.jpg)

View File

@ -0,0 +1,34 @@
[package]
name = "spl-governance"
version = "1.0.1"
description = "Solana Program Library Governance Program"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana-program-library"
license = "Apache-2.0"
edition = "2018"
[features]
no-entrypoint = []
test-bpf = []
[dependencies]
arrayref = "0.3.6"
bincode = "1.3.2"
borsh = "0.9.0"
num-derive = "0.3"
num-traits = "0.2"
serde = "1.0.126"
serde_derive = "1.0.103"
solana-program = "1.7.4"
spl-token = { version = "3.1.1", path = "../../token/program", features = [ "no-entrypoint" ] }
thiserror = "1.0"
[dev-dependencies]
assert_matches = "1.5.0"
base64 = "0.13"
proptest = "1.0"
solana-program-test = "1.7.4"
solana-sdk = "1.7.4"
[lib]
crate-type = ["cdylib", "lib"]

View File

@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []

View File

@ -0,0 +1,22 @@
//! Program entrypoint definitions
#![cfg(all(target_arch = "bpf", not(feature = "no-entrypoint")))]
use crate::{error::GovernanceError, processor};
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
program_error::PrintProgramError, pubkey::Pubkey,
};
entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
if let Err(error) = processor::process_instruction(program_id, accounts, instruction_data) {
// catch the error so we can print it
error.print::<GovernanceError>();
return Err(error);
}
Ok(())
}

View File

@ -0,0 +1,296 @@
//! Error types
use num_derive::FromPrimitive;
use solana_program::{
decode_error::DecodeError,
msg,
program_error::{PrintProgramError, ProgramError},
};
use thiserror::Error;
/// Errors that may be returned by the Governance program
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum GovernanceError {
/// Invalid instruction passed to program
#[error("Invalid instruction passed to program")]
InvalidInstruction = 500, // Start Governance custom errors from 500 to avoid conflicts with programs invoked via CPI
/// Realm with the given name and governing mints already exists
#[error("Realm with the given name and governing mints already exists")]
RealmAlreadyExists,
/// Invalid Realm
#[error("Invalid realm")]
InvalidRealm,
/// Invalid Governing Token Mint
#[error("Invalid Governing Token Mint")]
InvalidGoverningTokenMint,
/// Governing Token Owner must sign transaction
#[error("Governing Token Owner must sign transaction")]
GoverningTokenOwnerMustSign,
/// Governing Token Owner or Delegate must sign transaction
#[error("Governing Token Owner or Delegate must sign transaction")]
GoverningTokenOwnerOrDelegateMustSign,
/// All votes must be relinquished to withdraw governing tokens
#[error("All votes must be relinquished to withdraw governing tokens")]
AllVotesMustBeRelinquishedToWithdrawGoverningTokens,
/// Invalid Token Owner Record account address
#[error("Invalid Token Owner Record account address")]
InvalidTokenOwnerRecordAccountAddress,
/// Invalid GoverningMint for TokenOwnerRecord
#[error("Invalid GoverningMint for TokenOwnerRecord")]
InvalidGoverningMintForTokenOwnerRecord,
/// Invalid Realm for TokenOwnerRecord
#[error("Invalid Realm for TokenOwnerRecord")]
InvalidRealmForTokenOwnerRecord,
/// Invalid Proposal for ProposalInstruction
#[error("Invalid Proposal for ProposalInstruction")]
InvalidProposalForProposalInstruction,
/// Invalid Signatory account address
#[error("Invalid Signatory account address")]
InvalidSignatoryAddress,
/// Signatory already signed off
#[error("Signatory already signed off")]
SignatoryAlreadySignedOff,
/// Signatory must sign
#[error("Signatory must sign")]
SignatoryMustSign,
/// Invalid Proposal Owner
#[error("Invalid Proposal Owner")]
InvalidProposalOwnerAccount,
/// Invalid Proposal for VoterRecord
#[error("Invalid Proposal for VoterRecord")]
InvalidProposalForVoterRecord,
/// Invalid GoverningTokenOwner for VoteRecord
#[error("Invalid GoverningTokenOwner for VoteRecord")]
InvalidGoverningTokenOwnerForVoteRecord,
/// Invalid Governance config: Vote threshold percentage out of range"
#[error("Invalid Governance config: Vote threshold percentage out of range")]
InvalidVoteThresholdPercentage,
/// Proposal for the given Governance, Governing Token Mint and index already exists
#[error("Proposal for the given Governance, Governing Token Mint and index already exists")]
ProposalAlreadyExists,
/// Token Owner already voted on the Proposal
#[error("Token Owner already voted on the Proposal")]
VoteAlreadyExists,
/// Owner doesn't have enough governing tokens to create Proposal
#[error("Owner doesn't have enough governing tokens to create Proposal")]
NotEnoughTokensToCreateProposal,
/// Invalid State: Can't edit Signatories
#[error("Invalid State: Can't edit Signatories")]
InvalidStateCannotEditSignatories,
/// Invalid Proposal state
#[error("Invalid Proposal state")]
InvalidProposalState,
/// Invalid State: Can't edit instructions
#[error("Invalid State: Can't edit instructions")]
InvalidStateCannotEditInstructions,
/// Invalid State: Can't execute instruction
#[error("Invalid State: Can't execute instruction")]
InvalidStateCannotExecuteInstruction,
/// Can't execute instruction within its hold up time
#[error("Can't execute instruction within its hold up time")]
CannotExecuteInstructionWithinHoldUpTime,
/// Instruction already executed
#[error("Instruction already executed")]
InstructionAlreadyExecuted,
/// Invalid Instruction index
#[error("Invalid Instruction index")]
InvalidInstructionIndex,
/// Instruction hold up time is below the min specified by Governance
#[error("Instruction hold up time is below the min specified by Governance")]
InstructionHoldUpTimeBelowRequiredMin,
/// Instruction at the given index for the Proposal already exists
#[error("Instruction at the given index for the Proposal already exists")]
InstructionAlreadyExists,
/// Invalid State: Can't sign off
#[error("Invalid State: Can't sign off")]
InvalidStateCannotSignOff,
/// Invalid State: Can't vote
#[error("Invalid State: Can't vote")]
InvalidStateCannotVote,
/// Invalid State: Can't finalize vote
#[error("Invalid State: Can't finalize vote")]
InvalidStateCannotFinalize,
/// Invalid State: Can't cancel Proposal
#[error("Invalid State: Can't cancel Proposal")]
InvalidStateCannotCancelProposal,
/// Vote already relinquished
#[error("Vote already relinquished")]
VoteAlreadyRelinquished,
/// Can't finalize vote. Voting still in progress
#[error("Can't finalize vote. Voting still in progress")]
CannotFinalizeVotingInProgress,
/// Proposal voting time expired
#[error("Proposal voting time expired")]
ProposalVotingTimeExpired,
/// Invalid Signatory Mint
#[error("Invalid Signatory Mint")]
InvalidSignatoryMint,
/// ---- Account Tools Errors ----
/// Invalid account owner
#[error("Invalid account owner")]
InvalidAccountOwner,
/// Account doesn't exist
#[error("Account doesn't exist")]
AccountDoesNotExist,
/// Invalid Account type
#[error("Invalid Account type")]
InvalidAccountType,
/// Proposal does not belong to the given Governance
#[error("Proposal does not belong to the given Governance")]
InvalidGovernanceForProposal,
/// Proposal does not belong to given Governing Mint"
#[error("Proposal does not belong to given Governing Mint")]
InvalidGoverningMintForProposal,
/// Current mint authority must sign transaction
#[error("Current mint authority must sign transaction")]
MintAuthorityMustSign,
/// Invalid mint authority
#[error("Invalid mint authority")]
InvalidMintAuthority,
/// Mint has no authority
#[error("Mint has no authority")]
MintHasNoAuthority,
/// ---- SPL Token Tools Errors ----
/// Invalid Token account owner
#[error("Invalid Token account owner")]
SplTokenAccountWithInvalidOwner,
/// Invalid Mint account owner
#[error("Invalid Mint account owner")]
SplTokenMintWithInvalidOwner,
/// Token Account is not initialized
#[error("Token Account is not initialized")]
SplTokenAccountNotInitialized,
/// Token Account doesn't exist
#[error("Token Account doesn't exist")]
SplTokenAccountDoesNotExist,
/// Token account data is invalid
#[error("Token account data is invalid")]
SplTokenInvalidTokenAccountData,
/// Token mint account data is invalid
#[error("Token mint account data is invalid")]
SplTokenInvalidMintAccountData,
/// Token Mint is not initialized
#[error("Token Mint account is not initialized")]
SplTokenMintNotInitialized,
/// Token Mint account doesn't exist
#[error("Token Mint account doesn't exist")]
SplTokenMintDoesNotExist,
/// ---- Bpf Upgradable Loader Tools Errors ----
/// Invalid ProgramData account Address
#[error("Invalid ProgramData account address")]
InvalidProgramDataAccountAddress,
/// Invalid ProgramData account data
#[error("Invalid ProgramData account Data")]
InvalidProgramDataAccountData,
/// Provided upgrade authority doesn't match current program upgrade authority
#[error("Provided upgrade authority doesn't match current program upgrade authority")]
InvalidUpgradeAuthority,
/// Current program upgrade authority must sign transaction
#[error("Current program upgrade authority must sign transaction")]
UpgradeAuthorityMustSign,
/// Given program is not upgradable
#[error("Given program is not upgradable")]
ProgramNotUpgradable,
/// Invalid token owner
#[error("Invalid token owner")]
InvalidTokenOwner,
/// Current token owner must sign transaction
#[error("Current token owner must sign transaction")]
TokenOwnerMustSign,
/// Given VoteThresholdPercentageType is not supported
#[error("Given VoteThresholdPercentageType is not supported")]
VoteThresholdPercentageTypeNotSupported,
/// Given VoteWeightSource is not supported
#[error("Given VoteWeightSource is not supported")]
VoteWeightSourceNotSupported,
/// Proposal cool off time is not supported
#[error("Proposal cool off time is not supported")]
ProposalCoolOffTimeNotSupported,
/// Governance PDA must sign
#[error("Governance PDA must sign")]
GovernancePdaMustSign,
}
impl PrintProgramError for GovernanceError {
fn print<E>(&self) {
msg!("GOVERNANCE-ERROR: {}", &self.to_string());
}
}
impl From<GovernanceError> for ProgramError {
fn from(e: GovernanceError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for GovernanceError {
fn type_of() -> &'static str {
"Governance Error"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
#![deny(missing_docs)]
//! A Governance program for the Solana blockchain.
pub mod entrypoint;
pub mod error;
pub mod instruction;
pub mod processor;
pub mod state;
pub mod tools;
// Export current sdk types for downstream users building with a different sdk version
pub use solana_program;
/// Seed prefix for Governance PDAs
pub const PROGRAM_AUTHORITY_SEED: &[u8] = b"governance";

View File

@ -0,0 +1,164 @@
//! Program processor
mod process_add_signatory;
mod process_cancel_proposal;
mod process_cast_vote;
mod process_create_account_governance;
mod process_create_mint_governance;
mod process_create_program_governance;
mod process_create_proposal;
mod process_create_realm;
mod process_create_token_governance;
mod process_deposit_governing_tokens;
mod process_execute_instruction;
mod process_finalize_vote;
mod process_insert_instruction;
mod process_relinquish_vote;
mod process_remove_instruction;
mod process_remove_signatory;
mod process_set_governance_config;
mod process_set_governance_delegate;
mod process_sign_off_proposal;
mod process_withdraw_governing_tokens;
use crate::instruction::GovernanceInstruction;
use borsh::BorshDeserialize;
use process_add_signatory::*;
use process_cancel_proposal::*;
use process_cast_vote::*;
use process_create_account_governance::*;
use process_create_mint_governance::*;
use process_create_program_governance::*;
use process_create_proposal::*;
use process_create_realm::*;
use process_create_token_governance::*;
use process_deposit_governing_tokens::*;
use process_execute_instruction::*;
use process_finalize_vote::*;
use process_insert_instruction::*;
use process_relinquish_vote::*;
use process_remove_instruction::*;
use process_remove_signatory::*;
use process_set_governance_config::*;
use process_set_governance_delegate::*;
use process_sign_off_proposal::*;
use process_withdraw_governing_tokens::*;
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, msg, program_error::ProgramError,
pubkey::Pubkey,
};
/// Processes an instruction
pub fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
input: &[u8],
) -> ProgramResult {
let instruction = GovernanceInstruction::try_from_slice(input)
.map_err(|_| ProgramError::InvalidInstructionData)?;
if let GovernanceInstruction::InsertInstruction {
index,
hold_up_time,
instruction: _,
} = instruction
{
// Do not dump instruction data into logs
msg!(
"GOVERNANCE-INSTRUCTION: InsertInstruction {{ index: {:?}, hold_up_time: {:?} }}",
index,
hold_up_time
);
} else {
msg!("GOVERNANCE-INSTRUCTION: {:?}", instruction);
}
match instruction {
GovernanceInstruction::CreateRealm { name } => {
process_create_realm(program_id, accounts, name)
}
GovernanceInstruction::DepositGoverningTokens {} => {
process_deposit_governing_tokens(program_id, accounts)
}
GovernanceInstruction::WithdrawGoverningTokens {} => {
process_withdraw_governing_tokens(program_id, accounts)
}
GovernanceInstruction::SetGovernanceDelegate {
new_governance_delegate,
} => process_set_governance_delegate(program_id, accounts, &new_governance_delegate),
GovernanceInstruction::CreateProgramGovernance {
config,
transfer_upgrade_authority,
} => process_create_program_governance(
program_id,
accounts,
config,
transfer_upgrade_authority,
),
GovernanceInstruction::CreateMintGovernance {
config,
transfer_mint_authority,
} => process_create_mint_governance(program_id, accounts, config, transfer_mint_authority),
GovernanceInstruction::CreateTokenGovernance {
config,
transfer_token_owner,
} => process_create_token_governance(program_id, accounts, config, transfer_token_owner),
GovernanceInstruction::CreateAccountGovernance { config } => {
process_create_account_governance(program_id, accounts, config)
}
GovernanceInstruction::CreateProposal {
name,
description_link,
governing_token_mint,
} => process_create_proposal(
program_id,
accounts,
name,
description_link,
governing_token_mint,
),
GovernanceInstruction::AddSignatory { signatory } => {
process_add_signatory(program_id, accounts, signatory)
}
GovernanceInstruction::RemoveSignatory { signatory } => {
process_remove_signatory(program_id, accounts, signatory)
}
GovernanceInstruction::SignOffProposal {} => {
process_sign_off_proposal(program_id, accounts)
}
GovernanceInstruction::CastVote { vote } => process_cast_vote(program_id, accounts, vote),
GovernanceInstruction::FinalizeVote {} => process_finalize_vote(program_id, accounts),
GovernanceInstruction::RelinquishVote {} => process_relinquish_vote(program_id, accounts),
GovernanceInstruction::CancelProposal {} => process_cancel_proposal(program_id, accounts),
GovernanceInstruction::InsertInstruction {
index,
hold_up_time,
instruction,
} => process_insert_instruction(program_id, accounts, index, hold_up_time, instruction),
GovernanceInstruction::RemoveInstruction {} => {
process_remove_instruction(program_id, accounts)
}
GovernanceInstruction::ExecuteInstruction {} => {
process_execute_instruction(program_id, accounts)
}
GovernanceInstruction::SetGovernanceConfig { config } => {
process_set_governance_config(program_id, accounts, config)
}
}
}

View File

@ -0,0 +1,74 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
state::{
enums::GovernanceAccountType,
proposal::get_proposal_data,
signatory_record::{get_signatory_record_address_seeds, SignatoryRecord},
token_owner_record::get_token_owner_record_data_for_proposal_owner,
},
tools::account::create_and_serialize_account_signed,
};
/// Processes AddSignatory instruction
pub fn process_add_signatory(
program_id: &Pubkey,
accounts: &[AccountInfo],
signatory: Pubkey,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let token_owner_record_info = next_account_info(account_info_iter)?; // 1
let governance_authority_info = next_account_info(account_info_iter)?; // 2
let signatory_record_info = next_account_info(account_info_iter)?; // 3
let payer_info = next_account_info(account_info_iter)?; // 4
let system_info = next_account_info(account_info_iter)?; // 5
let rent_sysvar_info = next_account_info(account_info_iter)?; // 6
let rent = &Rent::from_account_info(rent_sysvar_info)?;
let mut proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_edit_signatories()?;
let token_owner_record_data = get_token_owner_record_data_for_proposal_owner(
program_id,
token_owner_record_info,
&proposal_data.token_owner_record,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
let signatory_record_data = SignatoryRecord {
account_type: GovernanceAccountType::SignatoryRecord,
proposal: *proposal_info.key,
signatory,
signed_off: false,
};
create_and_serialize_account_signed::<SignatoryRecord>(
payer_info,
signatory_record_info,
&signatory_record_data,
&get_signatory_record_address_seeds(proposal_info.key, &signatory),
program_id,
system_info,
rent,
)?;
proposal_data.signatories_count = proposal_data.signatories_count.checked_add(1).unwrap();
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,45 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
pubkey::Pubkey,
sysvar::Sysvar,
};
use crate::state::{
enums::ProposalState, proposal::get_proposal_data,
token_owner_record::get_token_owner_record_data_for_proposal_owner,
};
/// Processes CancelProposal instruction
pub fn process_cancel_proposal(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let token_owner_record_info = next_account_info(account_info_iter)?; // 1
let governance_authority_info = next_account_info(account_info_iter)?; // 2
let clock_info = next_account_info(account_info_iter)?; // 3
let clock = Clock::from_account_info(clock_info)?;
let mut proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_cancel()?;
let token_owner_record_data = get_token_owner_record_data_for_proposal_owner(
program_id,
token_owner_record_info,
&proposal_data.token_owner_record,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
proposal_data.state = ProposalState::Cancelled;
proposal_data.closed_at = Some(clock.unix_timestamp);
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,136 @@
//! Program state processor
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
error::GovernanceError,
instruction::Vote,
state::{
enums::{GovernanceAccountType, VoteWeight},
governance::get_governance_data,
proposal::get_proposal_data_for_governance_and_governing_mint,
token_owner_record::get_token_owner_record_data_for_realm_and_governing_mint,
vote_record::{get_vote_record_address_seeds, VoteRecord},
},
tools::{account::create_and_serialize_account_signed, spl_token::get_spl_token_mint_supply},
};
use borsh::BorshSerialize;
/// Processes CastVote instruction
pub fn process_cast_vote(
program_id: &Pubkey,
accounts: &[AccountInfo],
vote: Vote,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
let proposal_info = next_account_info(account_info_iter)?; // 1
let token_owner_record_info = next_account_info(account_info_iter)?; // 2
let governance_authority_info = next_account_info(account_info_iter)?; // 3
let vote_record_info = next_account_info(account_info_iter)?; // 4
let governing_token_mint_info = next_account_info(account_info_iter)?; // 5
let payer_info = next_account_info(account_info_iter)?; // 6
let system_info = next_account_info(account_info_iter)?; // 7
let rent_sysvar_info = next_account_info(account_info_iter)?; // 8
let rent = &Rent::from_account_info(rent_sysvar_info)?;
let clock_info = next_account_info(account_info_iter)?; // 9
let clock = Clock::from_account_info(clock_info)?;
if !vote_record_info.data_is_empty() {
return Err(GovernanceError::VoteAlreadyExists.into());
}
let governance_data = get_governance_data(program_id, governance_info)?;
let mut proposal_data = get_proposal_data_for_governance_and_governing_mint(
program_id,
proposal_info,
governance_info.key,
governing_token_mint_info.key,
)?;
proposal_data.assert_can_cast_vote(&governance_data.config, clock.unix_timestamp)?;
let mut token_owner_record_data = get_token_owner_record_data_for_realm_and_governing_mint(
program_id,
token_owner_record_info,
&governance_data.realm,
governing_token_mint_info.key,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
// Update TokenOwnerRecord vote counts
token_owner_record_data.unrelinquished_votes_count = token_owner_record_data
.unrelinquished_votes_count
.checked_add(1)
.unwrap();
token_owner_record_data.total_votes_count = token_owner_record_data
.total_votes_count
.checked_add(1)
.unwrap();
token_owner_record_data.serialize(&mut *token_owner_record_info.data.borrow_mut())?;
let vote_amount = token_owner_record_data.governing_token_deposit_amount;
// Calculate Proposal voting weights
let vote_weight = match vote {
Vote::Yes => {
proposal_data.yes_votes_count = proposal_data
.yes_votes_count
.checked_add(vote_amount)
.unwrap();
VoteWeight::Yes(vote_amount)
}
Vote::No => {
proposal_data.no_votes_count = proposal_data
.no_votes_count
.checked_add(vote_amount)
.unwrap();
VoteWeight::No(vote_amount)
}
};
let governing_token_supply = get_spl_token_mint_supply(governing_token_mint_info)?;
proposal_data.try_tip_vote(
governing_token_supply,
&governance_data.config,
clock.unix_timestamp,
);
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
// Create and serialize VoteRecord
let vote_record_data = VoteRecord {
account_type: GovernanceAccountType::VoteRecord,
proposal: *proposal_info.key,
governing_token_owner: token_owner_record_data.governing_token_owner,
vote_weight,
is_relinquished: false,
};
create_and_serialize_account_signed::<VoteRecord>(
payer_info,
vote_record_info,
&vote_record_data,
&get_vote_record_address_seeds(proposal_info.key, token_owner_record_info.key),
program_id,
system_info,
rent,
)?;
Ok(())
}

View File

@ -0,0 +1,60 @@
//! Program state processor
use crate::{
state::{
enums::GovernanceAccountType,
governance::{
assert_valid_create_governance_args, get_account_governance_address_seeds, Governance,
GovernanceConfig,
},
},
tools::account::create_and_serialize_account_signed,
};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
/// Processes CreateAccountGovernance instruction
pub fn process_create_account_governance(
program_id: &Pubkey,
accounts: &[AccountInfo],
config: GovernanceConfig,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let account_governance_info = next_account_info(account_info_iter)?; // 1
let governed_account_info = next_account_info(account_info_iter)?; // 2
let payer_info = next_account_info(account_info_iter)?; // 3
let system_info = next_account_info(account_info_iter)?; // 4
let rent_sysvar_info = next_account_info(account_info_iter)?; // 5
let rent = &Rent::from_account_info(rent_sysvar_info)?;
assert_valid_create_governance_args(program_id, &config, realm_info)?;
let account_governance_data = Governance {
account_type: GovernanceAccountType::AccountGovernance,
realm: *realm_info.key,
governed_account: *governed_account_info.key,
config,
proposals_count: 0,
reserved: [0; 8],
};
create_and_serialize_account_signed::<Governance>(
payer_info,
account_governance_info,
&account_governance_data,
&get_account_governance_address_seeds(realm_info.key, governed_account_info.key),
program_id,
system_info,
rent,
)?;
Ok(())
}

View File

@ -0,0 +1,83 @@
//! Program state processor
use crate::{
state::{
enums::GovernanceAccountType,
governance::{
assert_valid_create_governance_args, get_mint_governance_address_seeds, Governance,
GovernanceConfig,
},
},
tools::{
account::create_and_serialize_account_signed,
spl_token::{assert_spl_token_mint_authority_is_signer, set_spl_token_mint_authority},
},
};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
/// Processes CreateMintGovernance instruction
pub fn process_create_mint_governance(
program_id: &Pubkey,
accounts: &[AccountInfo],
config: GovernanceConfig,
transfer_mint_authority: bool,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let mint_governance_info = next_account_info(account_info_iter)?; // 1
let governed_mint_info = next_account_info(account_info_iter)?; // 2
let governed_mint_authority_info = next_account_info(account_info_iter)?; // 3
let payer_info = next_account_info(account_info_iter)?; // 4
let spl_token_info = next_account_info(account_info_iter)?; // 5
let system_info = next_account_info(account_info_iter)?; // 6
let rent_sysvar_info = next_account_info(account_info_iter)?; // 7
let rent = &Rent::from_account_info(rent_sysvar_info)?;
assert_valid_create_governance_args(program_id, &config, realm_info)?;
let mint_governance_data = Governance {
account_type: GovernanceAccountType::MintGovernance,
realm: *realm_info.key,
governed_account: *governed_mint_info.key,
config,
proposals_count: 0,
reserved: [0; 8],
};
create_and_serialize_account_signed::<Governance>(
payer_info,
mint_governance_info,
&mint_governance_data,
&get_mint_governance_address_seeds(realm_info.key, governed_mint_info.key),
program_id,
system_info,
rent,
)?;
if transfer_mint_authority {
set_spl_token_mint_authority(
governed_mint_info,
governed_mint_authority_info,
mint_governance_info.key,
spl_token_info,
)?;
} else {
assert_spl_token_mint_authority_is_signer(
governed_mint_info,
governed_mint_authority_info,
)?;
}
Ok(())
}

View File

@ -0,0 +1,89 @@
//! Program state processor
use crate::{
state::governance::Governance,
state::{
enums::GovernanceAccountType,
governance::{
assert_valid_create_governance_args, get_program_governance_address_seeds,
GovernanceConfig,
},
},
tools::{
account::create_and_serialize_account_signed,
bpf_loader_upgradeable::{
assert_program_upgrade_authority_is_signer, set_program_upgrade_authority,
},
},
};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
/// Processes CreateProgramGovernance instruction
pub fn process_create_program_governance(
program_id: &Pubkey,
accounts: &[AccountInfo],
config: GovernanceConfig,
transfer_upgrade_authority: bool,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let program_governance_info = next_account_info(account_info_iter)?; // 0
let governed_program_info = next_account_info(account_info_iter)?; // 1
let governed_program_data_info = next_account_info(account_info_iter)?; // 2
let governed_program_upgrade_authority_info = next_account_info(account_info_iter)?; // 3
let payer_info = next_account_info(account_info_iter)?; // 4
let bpf_upgrade_loader_info = next_account_info(account_info_iter)?; // 5
let system_info = next_account_info(account_info_iter)?; // 6
let rent_sysvar_info = next_account_info(account_info_iter)?; // 7
let rent = &Rent::from_account_info(rent_sysvar_info)?;
assert_valid_create_governance_args(program_id, &config, realm_info)?;
let program_governance_data = Governance {
account_type: GovernanceAccountType::ProgramGovernance,
realm: *realm_info.key,
governed_account: *governed_program_info.key,
config,
proposals_count: 0,
reserved: [0; 8],
};
create_and_serialize_account_signed::<Governance>(
payer_info,
program_governance_info,
&program_governance_data,
&get_program_governance_address_seeds(realm_info.key, governed_program_info.key),
program_id,
system_info,
rent,
)?;
if transfer_upgrade_authority {
set_program_upgrade_authority(
governed_program_info.key,
governed_program_data_info,
governed_program_upgrade_authority_info,
program_governance_info,
bpf_upgrade_loader_info,
)?;
} else {
assert_program_upgrade_authority_is_signer(
governed_program_info.key,
governed_program_data_info,
governed_program_upgrade_authority_info,
)?;
}
Ok(())
}

View File

@ -0,0 +1,120 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
error::GovernanceError,
state::{
enums::{GovernanceAccountType, InstructionExecutionFlags, ProposalState},
governance::get_governance_data,
proposal::{get_proposal_address_seeds, Proposal},
token_owner_record::get_token_owner_record_data_for_realm_and_governing_mint,
},
tools::account::create_and_serialize_account_signed,
};
/// Processes CreateProposal instruction
pub fn process_create_proposal(
program_id: &Pubkey,
accounts: &[AccountInfo],
name: String,
description_link: String,
governing_token_mint: Pubkey,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let governance_info = next_account_info(account_info_iter)?; // 1
let token_owner_record_info = next_account_info(account_info_iter)?; // 2
let governance_authority_info = next_account_info(account_info_iter)?; // 3
let payer_info = next_account_info(account_info_iter)?; // 4
let system_info = next_account_info(account_info_iter)?; // 5
let rent_sysvar_info = next_account_info(account_info_iter)?; // 6
let rent = &Rent::from_account_info(rent_sysvar_info)?;
let clock_info = next_account_info(account_info_iter)?; // 7
let clock = Clock::from_account_info(clock_info)?;
if !proposal_info.data_is_empty() {
return Err(GovernanceError::ProposalAlreadyExists.into());
}
let mut governance_data = get_governance_data(program_id, governance_info)?;
let token_owner_record_data = get_token_owner_record_data_for_realm_and_governing_mint(
program_id,
token_owner_record_info,
&governance_data.realm,
&governing_token_mint,
)?;
// proposal_owner must be either governing token owner or governance_delegate and must sign this transaction
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
if token_owner_record_data.governing_token_deposit_amount
< governance_data.config.min_tokens_to_create_proposal as u64
{
return Err(GovernanceError::NotEnoughTokensToCreateProposal.into());
}
let proposal_data = Proposal {
account_type: GovernanceAccountType::Proposal,
governance: *governance_info.key,
governing_token_mint,
state: ProposalState::Draft,
token_owner_record: *token_owner_record_info.key,
signatories_count: 0,
signatories_signed_off_count: 0,
name,
description_link,
draft_at: clock.unix_timestamp,
signing_off_at: None,
voting_at: None,
voting_at_slot: None,
voting_completed_at: None,
executing_at: None,
closed_at: None,
instructions_executed_count: 0,
instructions_count: 0,
instructions_next_index: 0,
execution_flags: InstructionExecutionFlags::None,
yes_votes_count: 0,
no_votes_count: 0,
};
create_and_serialize_account_signed::<Proposal>(
payer_info,
proposal_info,
&proposal_data,
&get_proposal_address_seeds(
governance_info.key,
&governing_token_mint,
&governance_data.proposals_count.to_le_bytes(),
),
program_id,
system_info,
rent,
)?;
governance_data.proposals_count = governance_data.proposals_count.checked_add(1).unwrap();
governance_data.serialize(&mut *governance_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,100 @@
//! Program state processor
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
error::GovernanceError,
state::{
enums::GovernanceAccountType,
realm::{get_governing_token_holding_address_seeds, get_realm_address_seeds, Realm},
},
tools::{
account::create_and_serialize_account_signed, spl_token::create_spl_token_account_signed,
},
};
/// Processes CreateRealm instruction
pub fn process_create_realm(
program_id: &Pubkey,
accounts: &[AccountInfo],
name: String,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let governance_token_mint_info = next_account_info(account_info_iter)?; // 1
let governance_token_holding_info = next_account_info(account_info_iter)?; // 2
let payer_info = next_account_info(account_info_iter)?; // 3
let system_info = next_account_info(account_info_iter)?; // 4
let spl_token_info = next_account_info(account_info_iter)?; // 5
let rent_sysvar_info = next_account_info(account_info_iter)?; // 6
let rent = &Rent::from_account_info(rent_sysvar_info)?;
if !realm_info.data_is_empty() {
return Err(GovernanceError::RealmAlreadyExists.into());
}
create_spl_token_account_signed(
payer_info,
governance_token_holding_info,
&get_governing_token_holding_address_seeds(realm_info.key, governance_token_mint_info.key),
governance_token_mint_info,
realm_info,
program_id,
system_info,
spl_token_info,
rent_sysvar_info,
rent,
)?;
let council_token_mint_address = if let Ok(council_token_mint_info) =
next_account_info(account_info_iter)
// 7
{
let council_token_holding_info = next_account_info(account_info_iter)?; //8
create_spl_token_account_signed(
payer_info,
council_token_holding_info,
&get_governing_token_holding_address_seeds(realm_info.key, council_token_mint_info.key),
council_token_mint_info,
realm_info,
program_id,
system_info,
spl_token_info,
rent_sysvar_info,
rent,
)?;
Some(*council_token_mint_info.key)
} else {
None
};
let realm_data = Realm {
account_type: GovernanceAccountType::Realm,
community_mint: *governance_token_mint_info.key,
council_mint: council_token_mint_address,
name: name.clone(),
reserved: [0; 8],
};
create_and_serialize_account_signed::<Realm>(
payer_info,
realm_info,
&realm_data,
&get_realm_address_seeds(&name),
program_id,
system_info,
rent,
)?;
Ok(())
}

View File

@ -0,0 +1,80 @@
//! Program state processor
use crate::{
state::{
enums::GovernanceAccountType,
governance::{
assert_valid_create_governance_args, get_token_governance_address_seeds, Governance,
GovernanceConfig,
},
},
tools::{
account::create_and_serialize_account_signed,
spl_token::{assert_spl_token_owner_is_signer, set_spl_token_owner},
},
};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
/// Processes CreateTokenGovernance instruction
pub fn process_create_token_governance(
program_id: &Pubkey,
accounts: &[AccountInfo],
config: GovernanceConfig,
transfer_token_owner: bool,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let token_governance_info = next_account_info(account_info_iter)?; // 1
let governed_token_info = next_account_info(account_info_iter)?; // 2
let governed_token_owner_info = next_account_info(account_info_iter)?; // 3
let payer_info = next_account_info(account_info_iter)?; // 4
let spl_token_info = next_account_info(account_info_iter)?; // 5
let system_info = next_account_info(account_info_iter)?; // 6
let rent_sysvar_info = next_account_info(account_info_iter)?; // 7
let rent = &Rent::from_account_info(rent_sysvar_info)?;
assert_valid_create_governance_args(program_id, &config, realm_info)?;
let token_governance_data = Governance {
account_type: GovernanceAccountType::TokenGovernance,
realm: *realm_info.key,
governed_account: *governed_token_info.key,
config,
proposals_count: 0,
reserved: [0; 8],
};
create_and_serialize_account_signed::<Governance>(
payer_info,
token_governance_info,
&token_governance_data,
&get_token_governance_address_seeds(realm_info.key, governed_token_info.key),
program_id,
system_info,
rent,
)?;
if transfer_token_owner {
set_spl_token_owner(
governed_token_info,
governed_token_owner_info,
token_governance_info.key,
spl_token_info,
)?;
} else {
assert_spl_token_owner_is_signer(governed_token_info, governed_token_owner_info)?;
}
Ok(())
}

View File

@ -0,0 +1,118 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
error::GovernanceError,
state::{
enums::GovernanceAccountType,
realm::get_realm_data,
token_owner_record::{
get_token_owner_record_address_seeds, get_token_owner_record_data_for_seeds,
TokenOwnerRecord,
},
},
tools::{
account::create_and_serialize_account_signed,
spl_token::{
get_spl_token_amount, get_spl_token_mint, get_spl_token_owner, transfer_spl_tokens,
},
},
};
/// Processes DepositGoverningTokens instruction
pub fn process_deposit_governing_tokens(
program_id: &Pubkey,
accounts: &[AccountInfo],
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let governing_token_holding_info = next_account_info(account_info_iter)?; // 1
let governing_token_source_info = next_account_info(account_info_iter)?; // 2
let governing_token_owner_info = next_account_info(account_info_iter)?; // 3
let governing_token_transfer_authority_info = next_account_info(account_info_iter)?; // 4
let token_owner_record_info = next_account_info(account_info_iter)?; // 5
let payer_info = next_account_info(account_info_iter)?; // 6
let system_info = next_account_info(account_info_iter)?; // 7
let spl_token_info = next_account_info(account_info_iter)?; // 8
let rent_sysvar_info = next_account_info(account_info_iter)?; // 9
let rent = &Rent::from_account_info(rent_sysvar_info)?;
let realm_data = get_realm_data(program_id, realm_info)?;
let governing_token_mint = get_spl_token_mint(governing_token_holding_info)?;
realm_data.assert_is_valid_governing_token_mint(&governing_token_mint)?;
let amount = get_spl_token_amount(governing_token_source_info)?;
transfer_spl_tokens(
governing_token_source_info,
governing_token_holding_info,
governing_token_transfer_authority_info,
amount,
spl_token_info,
)?;
let token_owner_record_address_seeds = get_token_owner_record_address_seeds(
realm_info.key,
&governing_token_mint,
governing_token_owner_info.key,
);
if token_owner_record_info.data_is_empty() {
// Deposited tokens can only be withdrawn by the owner so let's make sure the owner signed the transaction
let governing_token_owner = get_spl_token_owner(governing_token_source_info)?;
if !(governing_token_owner == *governing_token_owner_info.key
&& governing_token_owner_info.is_signer)
{
return Err(GovernanceError::GoverningTokenOwnerMustSign.into());
}
let token_owner_record_data = TokenOwnerRecord {
account_type: GovernanceAccountType::TokenOwnerRecord,
realm: *realm_info.key,
governing_token_owner: *governing_token_owner_info.key,
governing_token_deposit_amount: amount,
governing_token_mint,
governance_delegate: None,
unrelinquished_votes_count: 0,
total_votes_count: 0,
reserved: [0; 8],
};
create_and_serialize_account_signed(
payer_info,
token_owner_record_info,
&token_owner_record_data,
&token_owner_record_address_seeds,
program_id,
system_info,
rent,
)?;
} else {
let mut token_owner_record_data = get_token_owner_record_data_for_seeds(
program_id,
token_owner_record_info,
&token_owner_record_address_seeds,
)?;
token_owner_record_data.governing_token_deposit_amount = token_owner_record_data
.governing_token_deposit_amount
.checked_add(amount)
.unwrap();
token_owner_record_data.serialize(&mut *token_owner_record_info.data.borrow_mut())?;
}
Ok(())
}

View File

@ -0,0 +1,87 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
instruction::Instruction,
program::invoke_signed,
pubkey::Pubkey,
sysvar::Sysvar,
};
use crate::state::{
enums::{InstructionExecutionStatus, ProposalState},
governance::get_governance_data,
proposal::get_proposal_data_for_governance,
proposal_instruction::get_proposal_instruction_data_for_proposal,
};
/// Processes ExecuteInstruction instruction
pub fn process_execute_instruction(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
let proposal_info = next_account_info(account_info_iter)?; // 1
let proposal_instruction_info = next_account_info(account_info_iter)?; // 2
let clock_info = next_account_info(account_info_iter)?; // 3
let clock = Clock::from_account_info(clock_info)?;
let governance_data = get_governance_data(program_id, governance_info)?;
let mut proposal_data =
get_proposal_data_for_governance(program_id, proposal_info, governance_info.key)?;
let mut proposal_instruction_data = get_proposal_instruction_data_for_proposal(
program_id,
proposal_instruction_info,
proposal_info.key,
)?;
proposal_data
.assert_can_execute_instruction(&proposal_instruction_data, clock.unix_timestamp)?;
// Execute instruction with Governance PDA as signer
let instruction = Instruction::from(&proposal_instruction_data.instruction);
let instruction_account_infos = account_info_iter.as_slice();
let mut governance_seeds = governance_data.get_governance_address_seeds()?.to_vec();
let (_, bump_seed) = Pubkey::find_program_address(&governance_seeds, program_id);
let bump = &[bump_seed];
governance_seeds.push(bump);
invoke_signed(
&instruction,
instruction_account_infos,
&[&governance_seeds[..]],
)?;
// Update proposal and instruction accounts
if proposal_data.state == ProposalState::Succeeded {
proposal_data.executing_at = Some(clock.unix_timestamp);
proposal_data.state = ProposalState::Executing;
}
proposal_data.instructions_executed_count = proposal_data
.instructions_executed_count
.checked_add(1)
.unwrap();
if proposal_data.state == ProposalState::Executing
&& proposal_data.instructions_executed_count == proposal_data.instructions_count
{
proposal_data.closed_at = Some(clock.unix_timestamp);
proposal_data.state = ProposalState::Completed;
}
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
proposal_instruction_data.executed_at = Some(clock.unix_timestamp);
proposal_instruction_data.execution_status = InstructionExecutionStatus::Success;
proposal_instruction_data.serialize(&mut *proposal_instruction_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,53 @@
//! Program state processor
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
pubkey::Pubkey,
sysvar::Sysvar,
};
use crate::{
state::{
governance::get_governance_data,
proposal::get_proposal_data_for_governance_and_governing_mint,
},
tools::spl_token::get_spl_token_mint_supply,
};
use borsh::BorshSerialize;
/// Processes FinalizeVote instruction
pub fn process_finalize_vote(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
let proposal_info = next_account_info(account_info_iter)?; // 1
let governing_token_mint_info = next_account_info(account_info_iter)?; // 2
let clock_info = next_account_info(account_info_iter)?; // 3
let clock = Clock::from_account_info(clock_info)?;
let governance_data = get_governance_data(program_id, governance_info)?;
let mut proposal_data = get_proposal_data_for_governance_and_governing_mint(
program_id,
proposal_info,
governance_info.key,
governing_token_mint_info.key,
)?;
let governing_token_supply = get_spl_token_mint_supply(governing_token_mint_info)?;
proposal_data.finalize_vote(
governing_token_supply,
&governance_data.config,
clock.unix_timestamp,
)?;
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,113 @@
//! Program state processor
use std::cmp::Ordering;
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};
use crate::{
error::GovernanceError,
state::{
enums::{GovernanceAccountType, InstructionExecutionStatus},
governance::get_governance_data,
proposal::get_proposal_data_for_governance,
proposal_instruction::{
get_proposal_instruction_address_seeds, InstructionData, ProposalInstruction,
},
token_owner_record::get_token_owner_record_data_for_proposal_owner,
},
tools::account::create_and_serialize_account_signed,
};
/// Processes InsertInstruction instruction
pub fn process_insert_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_index: u16,
hold_up_time: u32,
instruction: InstructionData,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
let proposal_info = next_account_info(account_info_iter)?; // 1
let token_owner_record_info = next_account_info(account_info_iter)?; // 2
let governance_authority_info = next_account_info(account_info_iter)?; // 3
let proposal_instruction_info = next_account_info(account_info_iter)?; // 4
let payer_info = next_account_info(account_info_iter)?; // 5
let system_info = next_account_info(account_info_iter)?; // 6
let rent_sysvar_info = next_account_info(account_info_iter)?; // 7
let rent = &Rent::from_account_info(rent_sysvar_info)?;
if !proposal_instruction_info.data_is_empty() {
return Err(GovernanceError::InstructionAlreadyExists.into());
}
let governance_data = get_governance_data(program_id, governance_info)?;
if hold_up_time < governance_data.config.min_instruction_hold_up_time {
return Err(GovernanceError::InstructionHoldUpTimeBelowRequiredMin.into());
}
let mut proposal_data =
get_proposal_data_for_governance(program_id, proposal_info, governance_info.key)?;
proposal_data.assert_can_edit_instructions()?;
let token_owner_record_data = get_token_owner_record_data_for_proposal_owner(
program_id,
token_owner_record_info,
&proposal_data.token_owner_record,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
match instruction_index.cmp(&proposal_data.instructions_next_index) {
Ordering::Greater => return Err(GovernanceError::InvalidInstructionIndex.into()),
// If the index is the same as instructions_next_index then we are adding a new instruction
// If the index is below instructions_next_index then we are inserting into an existing empty space
Ordering::Equal => {
proposal_data.instructions_next_index = proposal_data
.instructions_next_index
.checked_add(1)
.unwrap();
}
Ordering::Less => {}
}
proposal_data.instructions_count = proposal_data.instructions_count.checked_add(1).unwrap();
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
let proposal_instruction_data = ProposalInstruction {
account_type: GovernanceAccountType::ProposalInstruction,
instruction_index,
hold_up_time,
instruction,
executed_at: None,
execution_status: InstructionExecutionStatus::None,
proposal: *proposal_info.key,
};
create_and_serialize_account_signed::<ProposalInstruction>(
payer_info,
proposal_instruction_info,
&proposal_instruction_data,
&get_proposal_instruction_address_seeds(
proposal_info.key,
&instruction_index.to_le_bytes(),
),
program_id,
system_info,
rent,
)?;
Ok(())
}

View File

@ -0,0 +1,103 @@
//! Program state processor
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
state::{
enums::{ProposalState, VoteWeight},
governance::get_governance_data,
proposal::get_proposal_data_for_governance_and_governing_mint,
token_owner_record::get_token_owner_record_data_for_realm_and_governing_mint,
vote_record::get_vote_record_data_for_proposal_and_token_owner,
},
tools::account::dispose_account,
};
use borsh::BorshSerialize;
/// Processes RelinquishVote instruction
pub fn process_relinquish_vote(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
let proposal_info = next_account_info(account_info_iter)?; // 1
let token_owner_record_info = next_account_info(account_info_iter)?; // 2
let vote_record_info = next_account_info(account_info_iter)?; // 3
let governing_token_mint_info = next_account_info(account_info_iter)?; // 4
let governance_data = get_governance_data(program_id, governance_info)?;
let mut proposal_data = get_proposal_data_for_governance_and_governing_mint(
program_id,
proposal_info,
governance_info.key,
governing_token_mint_info.key,
)?;
let mut token_owner_record_data = get_token_owner_record_data_for_realm_and_governing_mint(
program_id,
token_owner_record_info,
&governance_data.realm,
governing_token_mint_info.key,
)?;
let mut vote_record_data = get_vote_record_data_for_proposal_and_token_owner(
program_id,
vote_record_info,
proposal_info.key,
&token_owner_record_data.governing_token_owner,
)?;
vote_record_data.assert_can_relinquish_vote()?;
// If the Proposal is still being voted on then the token owner vote won't count towards the outcome
if proposal_data.state == ProposalState::Voting {
let governance_authority_info = next_account_info(account_info_iter)?; // 5
let beneficiary_info = next_account_info(account_info_iter)?; // 6
// Note: It's only required to sign by governing_authority if relinquishing the vote results in vote change
// If the Proposal is already decided then anybody can prune active votes for token owner
token_owner_record_data
.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
match vote_record_data.vote_weight {
VoteWeight::Yes(vote_amount) => {
proposal_data.yes_votes_count = proposal_data
.yes_votes_count
.checked_sub(vote_amount)
.unwrap();
}
VoteWeight::No(vote_amount) => {
proposal_data.no_votes_count = proposal_data
.no_votes_count
.checked_sub(vote_amount)
.unwrap();
}
};
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
dispose_account(vote_record_info, beneficiary_info);
token_owner_record_data.total_votes_count = token_owner_record_data
.total_votes_count
.checked_sub(1)
.unwrap();
} else {
vote_record_data.is_relinquished = true;
vote_record_data.serialize(&mut *vote_record_info.data.borrow_mut())?;
}
// If the Proposal has been already voted on then we only have to decrease unrelinquished_votes_count
token_owner_record_data.unrelinquished_votes_count = token_owner_record_data
.unrelinquished_votes_count
.checked_sub(1)
.unwrap();
token_owner_record_data.serialize(&mut *token_owner_record_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,54 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
state::{
proposal::get_proposal_data,
proposal_instruction::assert_proposal_instruction_for_proposal,
token_owner_record::get_token_owner_record_data_for_proposal_owner,
},
tools::account::dispose_account,
};
/// Processes RemoveInstruction instruction
pub fn process_remove_instruction(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let token_owner_record_info = next_account_info(account_info_iter)?; // 1
let governance_authority_info = next_account_info(account_info_iter)?; // 2
let proposal_instruction_info = next_account_info(account_info_iter)?; // 3
let beneficiary_info = next_account_info(account_info_iter)?; // 4
let mut proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_edit_instructions()?;
let token_owner_record_data = get_token_owner_record_data_for_proposal_owner(
program_id,
token_owner_record_info,
&proposal_data.token_owner_record,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
assert_proposal_instruction_for_proposal(
program_id,
proposal_instruction_info,
proposal_info.key,
)?;
dispose_account(proposal_instruction_info, beneficiary_info);
proposal_data.instructions_count = proposal_data.instructions_count.checked_sub(1).unwrap();
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,59 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
state::{
proposal::get_proposal_data, signatory_record::get_signatory_record_data_for_seeds,
token_owner_record::get_token_owner_record_data_for_proposal_owner,
},
tools::account::dispose_account,
};
/// Processes RemoveSignatory instruction
pub fn process_remove_signatory(
program_id: &Pubkey,
accounts: &[AccountInfo],
signatory: Pubkey,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let token_owner_record_info = next_account_info(account_info_iter)?; // 1
let governance_authority_info = next_account_info(account_info_iter)?; // 2
let signatory_record_info = next_account_info(account_info_iter)?; // 3
let beneficiary_info = next_account_info(account_info_iter)?; // 4
let mut proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_edit_signatories()?;
let token_owner_record_data = get_token_owner_record_data_for_proposal_owner(
program_id,
token_owner_record_info,
&proposal_data.token_owner_record,
)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
let signatory_record_data = get_signatory_record_data_for_seeds(
program_id,
signatory_record_info,
proposal_info.key,
&signatory,
)?;
signatory_record_data.assert_can_remove_signatory()?;
proposal_data.signatories_count = proposal_data.signatories_count.checked_sub(1).unwrap();
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
dispose_account(signatory_record_info, beneficiary_info);
Ok(())
}

View File

@ -0,0 +1,38 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
error::GovernanceError,
state::governance::{assert_is_valid_governance_config, get_governance_data, GovernanceConfig},
};
/// Processes SetGovernanceConfig instruction
pub fn process_set_governance_config(
program_id: &Pubkey,
accounts: &[AccountInfo],
config: GovernanceConfig,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_info = next_account_info(account_info_iter)?; // 0
// Only governance PDA via a proposal can authorize change to its own config
if !governance_info.is_signer {
return Err(GovernanceError::GovernancePdaMustSign.into());
}
assert_is_valid_governance_config(&config)?;
let mut governance_data = get_governance_data(program_id, governance_info)?;
governance_data.config = config;
governance_data.serialize(&mut *governance_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,32 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::state::token_owner_record::get_token_owner_record_data;
/// Processes SetGovernanceDelegate instruction
pub fn process_set_governance_delegate(
program_id: &Pubkey,
accounts: &[AccountInfo],
new_governance_delegate: &Option<Pubkey>,
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let governance_authority_info = next_account_info(account_info_iter)?; // 0
let token_owner_record_info = next_account_info(account_info_iter)?; // 1
let mut token_owner_record_data =
get_token_owner_record_data(program_id, token_owner_record_info)?;
token_owner_record_data.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
token_owner_record_data.governance_delegate = *new_governance_delegate;
token_owner_record_data.serialize(&mut *token_owner_record_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,63 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
clock::Clock,
entrypoint::ProgramResult,
pubkey::Pubkey,
sysvar::Sysvar,
};
use crate::state::{
enums::ProposalState, proposal::get_proposal_data,
signatory_record::get_signatory_record_data_for_seeds,
};
/// Processes SignOffProposal instruction
pub fn process_sign_off_proposal(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let signatory_record_info = next_account_info(account_info_iter)?; // 1
let signatory_info = next_account_info(account_info_iter)?; // 2
let clock_info = next_account_info(account_info_iter)?; // 3
let clock = Clock::from_account_info(clock_info)?;
let mut proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_sign_off()?;
let mut signatory_record_data = get_signatory_record_data_for_seeds(
program_id,
signatory_record_info,
proposal_info.key,
signatory_info.key,
)?;
signatory_record_data.assert_can_sign_off(signatory_info)?;
signatory_record_data.signed_off = true;
signatory_record_data.serialize(&mut *signatory_record_info.data.borrow_mut())?;
if proposal_data.signatories_signed_off_count == 0 {
proposal_data.signing_off_at = Some(clock.unix_timestamp);
proposal_data.state = ProposalState::SigningOff;
}
proposal_data.signatories_signed_off_count = proposal_data
.signatories_signed_off_count
.checked_add(1)
.unwrap();
// If all Signatories signed off we can start voting
if proposal_data.signatories_signed_off_count == proposal_data.signatories_count {
proposal_data.voting_at = Some(clock.unix_timestamp);
proposal_data.voting_at_slot = Some(clock.slot);
proposal_data.state = ProposalState::Voting;
}
proposal_data.serialize(&mut *proposal_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,72 @@
//! Program state processor
use borsh::BorshSerialize;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
error::GovernanceError,
state::{
realm::{get_realm_address_seeds, get_realm_data},
token_owner_record::{
get_token_owner_record_address_seeds, get_token_owner_record_data_for_seeds,
},
},
tools::spl_token::{get_spl_token_mint, transfer_spl_tokens_signed},
};
/// Processes WithdrawGoverningTokens instruction
pub fn process_withdraw_governing_tokens(
program_id: &Pubkey,
accounts: &[AccountInfo],
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let realm_info = next_account_info(account_info_iter)?; // 0
let governing_token_holding_info = next_account_info(account_info_iter)?; // 1
let governing_token_destination_info = next_account_info(account_info_iter)?; // 2
let governing_token_owner_info = next_account_info(account_info_iter)?; // 3
let token_owner_record_info = next_account_info(account_info_iter)?; // 4
let spl_token_info = next_account_info(account_info_iter)?; // 5
if !governing_token_owner_info.is_signer {
return Err(GovernanceError::GoverningTokenOwnerMustSign.into());
}
let realm_data = get_realm_data(program_id, realm_info)?;
let governing_token_mint = get_spl_token_mint(governing_token_holding_info)?;
let token_owner_record_address_seeds = get_token_owner_record_address_seeds(
realm_info.key,
&governing_token_mint,
governing_token_owner_info.key,
);
let mut token_owner_record_data = get_token_owner_record_data_for_seeds(
program_id,
token_owner_record_info,
&token_owner_record_address_seeds,
)?;
if token_owner_record_data.unrelinquished_votes_count > 0 {
return Err(GovernanceError::AllVotesMustBeRelinquishedToWithdrawGoverningTokens.into());
}
transfer_spl_tokens_signed(
governing_token_holding_info,
governing_token_destination_info,
realm_info,
&get_realm_address_seeds(&realm_data.name),
program_id,
token_owner_record_data.governing_token_deposit_amount,
spl_token_info,
)?;
token_owner_record_data.governing_token_deposit_amount = 0;
token_owner_record_data.serialize(&mut *token_owner_record_info.data.borrow_mut())?;
Ok(())
}

View File

@ -0,0 +1,158 @@
//! State enumerations
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
/// Defines all Governance accounts types
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum GovernanceAccountType {
/// Default uninitialized account state
Uninitialized,
/// Top level aggregation for governances with Community Token (and optional Council Token)
Realm,
/// Token Owner Record for given governing token owner within a Realm
TokenOwnerRecord,
/// Generic Account Governance account
AccountGovernance,
/// Program Governance account
ProgramGovernance,
/// Proposal account for Governance account. A single Governance account can have multiple Proposal accounts
Proposal,
/// Proposal Signatory account
SignatoryRecord,
/// Vote record account for a given Proposal. Proposal can have 0..n voting records
VoteRecord,
/// ProposalInstruction account which holds an instruction to execute for Proposal
ProposalInstruction,
/// Mint Governance account
MintGovernance,
/// Token Governance account
TokenGovernance,
}
impl Default for GovernanceAccountType {
fn default() -> Self {
GovernanceAccountType::Uninitialized
}
}
/// Vote with number of votes
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum VoteWeight {
/// Yes vote
Yes(u64),
/// No vote
No(u64),
}
/// What state a Proposal is in
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum ProposalState {
/// Draft - Proposal enters Draft state when it's created
Draft,
/// SigningOff - The Proposal is being signed off by Signatories
/// Proposal enters the state when first Signatory Sings and leaves it when last Signatory signs
SigningOff,
/// Taking votes
Voting,
/// Voting ended with success
Succeeded,
/// Voting completed and now instructions are being execute. Proposal enter this state when first instruction is executed and leaves when the last instruction is executed
Executing,
/// Completed
Completed,
/// Cancelled
Cancelled,
/// Defeated
Defeated,
}
impl Default for ProposalState {
fn default() -> Self {
ProposalState::Draft
}
}
/// The type of the vote threshold percentage used to resolve a vote on a Proposal
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum VoteThresholdPercentage {
/// Voting threshold of Yes votes in % required to tip the vote
/// It's the percentage of tokens out of the entire pool of governance tokens eligible to vote
/// Note: If the threshold is below or equal to 50% then an even split of votes ex: 50:50 or 40:40 is always resolved as Defeated
/// In other words a '+1 vote' tie breaker is always required to have a successful vote
YesVote(u8),
/// The minimum number of votes in % out of the entire pool of governance tokens eligible to vote
/// which must be cast for the vote to be valid
/// Once the quorum is achieved a simple majority (50%+1) of Yes votes is required for the vote to succeed
/// Note: Quorum is not implemented in the current version
Quorum(u8),
}
/// The source of voter weights used to vote on proposals
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum VoteWeightSource {
/// Governing token deposits into the Realm are used as voter weights
Deposit,
/// Governing token account snapshots as of the time a proposal entered voting state are used as voter weights
/// Note: Snapshot source is not supported in the current version
/// Support for account snapshots are required in solana and/or arweave as a prerequisite
Snapshot,
}
/// The status of instruction execution
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum InstructionExecutionStatus {
/// Instruction was not executed yet
None,
/// Instruction was executed successfully
Success,
/// Instruction execution failed
/// Note: Error status is not supported yet because when CPI call fails it always terminates parent instruction
/// We either have to make it possible to change that behavior or add an instruction to manually set the status
Error,
}
/// Instruction execution flags defining how instructions are executed for a Proposal
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum InstructionExecutionFlags {
/// No execution flags are specified
/// Instructions can be executed individually, in any order, as soon as they hold_up time expires
None,
/// Instructions are executed in a specific order
/// Note: Ordered execution is not supported in the current version
/// The implementation requires another account type to track deleted instructions
Ordered,
/// Multiple instructions can be executed as a single transaction
/// Note: Transactions are not supported in the current version
/// The implementation requires another account type to group instructions within a transaction
UseTransaction,
}

View File

@ -0,0 +1,244 @@
//! Governance Account
use crate::{
error::GovernanceError,
state::{
enums::{GovernanceAccountType, VoteThresholdPercentage, VoteWeightSource},
realm::assert_is_valid_realm,
},
tools::account::{get_account_data, AccountMaxSize},
};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo, program_error::ProgramError, program_pack::IsInitialized,
pubkey::Pubkey,
};
/// Governance config
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct GovernanceConfig {
/// The type of the vote threshold used for voting
/// Note: In the current version only YesVote threshold is supported
pub vote_threshold_percentage: VoteThresholdPercentage,
/// Minimum number of tokens a governance token owner must possess to be able to create a proposal
pub min_tokens_to_create_proposal: u64,
/// Minimum waiting time in seconds for an instruction to be executed after proposal is voted on
pub min_instruction_hold_up_time: u32,
/// Time limit in seconds for proposal to be open for voting
pub max_voting_time: u32,
/// The source of vote weight for voters
/// Note: In the current version only token deposits are accepted as vote weight
pub vote_weight_source: VoteWeightSource,
/// The time period in seconds within which a Proposal can be still cancelled after being voted on
/// Once cool off time expires Proposal can't be cancelled any longer and becomes a law
/// Note: This field is not implemented in the current version
pub proposal_cool_off_time: u32,
}
/// Governance Account
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct Governance {
/// Account type. It can be Uninitialized, AccountGovernance or ProgramGovernance
pub account_type: GovernanceAccountType,
/// Governance Realm
pub realm: Pubkey,
/// Account governed by this Governance. It can be for example Program account, Mint account or Token Account
pub governed_account: Pubkey,
/// Governance config
pub config: GovernanceConfig,
/// Reserved space for future versions
pub reserved: [u8; 8],
/// Running count of proposals
pub proposals_count: u32,
}
impl AccountMaxSize for Governance {}
impl IsInitialized for Governance {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::AccountGovernance
|| self.account_type == GovernanceAccountType::ProgramGovernance
|| self.account_type == GovernanceAccountType::MintGovernance
|| self.account_type == GovernanceAccountType::TokenGovernance
}
}
impl Governance {
/// Returns Governance PDA seeds
pub fn get_governance_address_seeds(&self) -> Result<[&[u8]; 3], ProgramError> {
let seeds = match self.account_type {
GovernanceAccountType::AccountGovernance => {
get_account_governance_address_seeds(&self.realm, &self.governed_account)
}
GovernanceAccountType::ProgramGovernance => {
get_program_governance_address_seeds(&self.realm, &self.governed_account)
}
GovernanceAccountType::MintGovernance => {
get_mint_governance_address_seeds(&self.realm, &self.governed_account)
}
GovernanceAccountType::TokenGovernance => {
get_token_governance_address_seeds(&self.realm, &self.governed_account)
}
_ => return Err(GovernanceError::InvalidAccountType.into()),
};
Ok(seeds)
}
}
/// Deserializes account and checks owner program
pub fn get_governance_data(
program_id: &Pubkey,
governance_info: &AccountInfo,
) -> Result<Governance, ProgramError> {
get_account_data::<Governance>(governance_info, program_id)
}
/// Returns ProgramGovernance PDA seeds
pub fn get_program_governance_address_seeds<'a>(
realm: &'a Pubkey,
governed_program: &'a Pubkey,
) -> [&'a [u8]; 3] {
// 'program-governance' prefix ensures uniqueness of the PDA
// Note: Only the current program upgrade authority can create an account with this PDA using CreateProgramGovernance instruction
[
b"program-governance",
realm.as_ref(),
governed_program.as_ref(),
]
}
/// Returns ProgramGovernance PDA address
pub fn get_program_governance_address<'a>(
program_id: &Pubkey,
realm: &'a Pubkey,
governed_program: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_program_governance_address_seeds(realm, governed_program),
program_id,
)
.0
}
/// Returns MintGovernance PDA seeds
pub fn get_mint_governance_address_seeds<'a>(
realm: &'a Pubkey,
governed_mint: &'a Pubkey,
) -> [&'a [u8]; 3] {
// 'mint-governance' prefix ensures uniqueness of the PDA
// Note: Only the current mint authority can create an account with this PDA using CreateMintGovernance instruction
[b"mint-governance", realm.as_ref(), governed_mint.as_ref()]
}
/// Returns MintGovernance PDA address
pub fn get_mint_governance_address<'a>(
program_id: &Pubkey,
realm: &'a Pubkey,
governed_mint: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_mint_governance_address_seeds(realm, governed_mint),
program_id,
)
.0
}
/// Returns TokenGovernance PDA seeds
pub fn get_token_governance_address_seeds<'a>(
realm: &'a Pubkey,
governed_token: &'a Pubkey,
) -> [&'a [u8]; 3] {
// 'token-governance' prefix ensures uniqueness of the PDA
// Note: Only the current token account owner can create an account with this PDA using CreateTokenGovernance instruction
[b"token-governance", realm.as_ref(), governed_token.as_ref()]
}
/// Returns TokenGovernance PDA address
pub fn get_token_governance_address<'a>(
program_id: &Pubkey,
realm: &'a Pubkey,
governed_token: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_token_governance_address_seeds(realm, governed_token),
program_id,
)
.0
}
/// Returns AccountGovernance PDA seeds
pub fn get_account_governance_address_seeds<'a>(
realm: &'a Pubkey,
governed_account: &'a Pubkey,
) -> [&'a [u8]; 3] {
[
b"account-governance",
realm.as_ref(),
governed_account.as_ref(),
]
}
/// Returns AccountGovernance PDA address
pub fn get_account_governance_address<'a>(
program_id: &Pubkey,
realm: &'a Pubkey,
governed_account: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_account_governance_address_seeds(realm, governed_account),
program_id,
)
.0
}
/// Validates args supplied to create governance account
pub fn assert_valid_create_governance_args(
program_id: &Pubkey,
governance_config: &GovernanceConfig,
realm_info: &AccountInfo,
) -> Result<(), ProgramError> {
assert_is_valid_realm(program_id, realm_info)?;
assert_is_valid_governance_config(governance_config)?;
Ok(())
}
/// Validates governance config parameters
pub fn assert_is_valid_governance_config(
governance_config: &GovernanceConfig,
) -> Result<(), ProgramError> {
match governance_config.vote_threshold_percentage {
VoteThresholdPercentage::YesVote(yes_vote_threshold_percentage) => {
if !(1..=100).contains(&yes_vote_threshold_percentage) {
return Err(GovernanceError::InvalidVoteThresholdPercentage.into());
}
}
_ => {
return Err(GovernanceError::VoteThresholdPercentageTypeNotSupported.into());
}
}
if governance_config.vote_weight_source != VoteWeightSource::Deposit {
return Err(GovernanceError::VoteWeightSourceNotSupported.into());
}
if governance_config.proposal_cool_off_time > 0 {
return Err(GovernanceError::ProposalCoolOffTimeNotSupported.into());
}
Ok(())
}

View File

@ -0,0 +1,10 @@
//! Program accounts
pub mod enums;
pub mod governance;
pub mod proposal;
pub mod proposal_instruction;
pub mod realm;
pub mod signatory_record;
pub mod token_owner_record;
pub mod vote_record;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,282 @@
//! ProposalInstruction Account
use crate::{
error::GovernanceError,
state::enums::{GovernanceAccountType, InstructionExecutionStatus},
tools::account::{get_account_data, AccountMaxSize},
PROGRAM_AUTHORITY_SEED,
};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo,
clock::UnixTimestamp,
instruction::{AccountMeta, Instruction},
program_error::ProgramError,
program_pack::IsInitialized,
pubkey::Pubkey,
};
/// InstructionData wrapper. It can be removed once Borsh serialization for Instruction is supported in the SDK
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
#[repr(C)]
pub struct InstructionData {
/// Pubkey of the instruction processor that executes this instruction
pub program_id: Pubkey,
/// Metadata for what accounts should be passed to the instruction processor
pub accounts: Vec<AccountMetaData>,
/// Opaque data passed to the instruction processor
pub data: Vec<u8>,
}
/// Account metadata used to define Instructions
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
#[repr(C)]
pub struct AccountMetaData {
/// An account's public key
pub pubkey: Pubkey,
/// True if an Instruction requires a Transaction signature matching `pubkey`.
pub is_signer: bool,
/// True if the `pubkey` can be loaded as a read-write account.
pub is_writable: bool,
}
impl From<Instruction> for InstructionData {
fn from(instruction: Instruction) -> Self {
InstructionData {
program_id: instruction.program_id,
accounts: instruction
.accounts
.iter()
.map(|a| AccountMetaData {
pubkey: a.pubkey,
is_signer: a.is_signer,
is_writable: a.is_writable,
})
.collect(),
data: instruction.data,
}
}
}
impl From<&InstructionData> for Instruction {
fn from(instruction: &InstructionData) -> Self {
Instruction {
program_id: instruction.program_id,
accounts: instruction
.accounts
.iter()
.map(|a| AccountMeta {
pubkey: a.pubkey,
is_signer: a.is_signer,
is_writable: a.is_writable,
})
.collect(),
data: instruction.data.clone(),
}
}
}
/// Account for an instruction to be executed for Proposal
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct ProposalInstruction {
/// Governance Account type
pub account_type: GovernanceAccountType,
/// The Proposal the instruction belongs to
pub proposal: Pubkey,
/// Unique instruction index within it's parent Proposal
pub instruction_index: u16,
/// Minimum waiting time in seconds for the instruction to be executed once proposal is voted on
pub hold_up_time: u32,
/// Instruction to execute
/// The instruction will be signed by Governance PDA the Proposal belongs to
// For example for ProgramGovernance the instruction to upgrade program will be signed by ProgramGovernance PDA
pub instruction: InstructionData,
/// Executed at flag
pub executed_at: Option<UnixTimestamp>,
/// Instruction execution status
/// Note: The field is not used in the current version
pub execution_status: InstructionExecutionStatus,
}
impl AccountMaxSize for ProposalInstruction {
fn get_max_size(&self) -> Option<usize> {
Some(self.instruction.accounts.len() * 34 + self.instruction.data.len() + 89)
}
}
impl IsInitialized for ProposalInstruction {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::ProposalInstruction
}
}
/// Returns ProposalInstruction PDA seeds
pub fn get_proposal_instruction_address_seeds<'a>(
proposal: &'a Pubkey,
instruction_index_le_bytes: &'a [u8],
) -> [&'a [u8]; 3] {
[
PROGRAM_AUTHORITY_SEED,
proposal.as_ref(),
instruction_index_le_bytes,
]
}
/// Returns ProposalInstruction PDA address
pub fn get_proposal_instruction_address<'a>(
program_id: &Pubkey,
proposal: &'a Pubkey,
instruction_index_le_bytes: &'a [u8],
) -> Pubkey {
Pubkey::find_program_address(
&get_proposal_instruction_address_seeds(proposal, instruction_index_le_bytes),
program_id,
)
.0
}
/// Deserializes ProposalInstruction account and checks owner program
pub fn get_proposal_instruction_data(
program_id: &Pubkey,
proposal_instruction_info: &AccountInfo,
) -> Result<ProposalInstruction, ProgramError> {
get_account_data::<ProposalInstruction>(proposal_instruction_info, program_id)
}
/// Deserializes and returns ProposalInstruction account and checks it belongs to the given Proposal
pub fn get_proposal_instruction_data_for_proposal(
program_id: &Pubkey,
proposal_instruction_info: &AccountInfo,
proposal: &Pubkey,
) -> Result<ProposalInstruction, ProgramError> {
let proposal_instruction_data =
get_proposal_instruction_data(program_id, proposal_instruction_info)?;
if proposal_instruction_data.proposal != *proposal {
return Err(GovernanceError::InvalidProposalForProposalInstruction.into());
}
Ok(proposal_instruction_data)
}
/// Deserializes ProposalInstruction account and checks it belongs to the given Proposal
pub fn assert_proposal_instruction_for_proposal(
program_id: &Pubkey,
proposal_instruction_info: &AccountInfo,
proposal: &Pubkey,
) -> Result<(), ProgramError> {
get_proposal_instruction_data_for_proposal(program_id, proposal_instruction_info, proposal)
.map(|_| ())
}
#[cfg(test)]
mod test {
use std::str::FromStr;
use solana_program::bpf_loader_upgradeable;
use super::*;
fn create_test_account_meta_data() -> AccountMetaData {
AccountMetaData {
pubkey: Pubkey::new_unique(),
is_signer: true,
is_writable: false,
}
}
fn create_test_instruction_data() -> InstructionData {
InstructionData {
program_id: Pubkey::new_unique(),
accounts: vec![
create_test_account_meta_data(),
create_test_account_meta_data(),
],
data: vec![1, 2, 3],
}
}
fn create_test_proposal_instruction() -> ProposalInstruction {
ProposalInstruction {
account_type: GovernanceAccountType::ProposalInstruction,
proposal: Pubkey::new_unique(),
instruction_index: 1,
hold_up_time: 10,
instruction: create_test_instruction_data(),
executed_at: Some(100),
execution_status: InstructionExecutionStatus::Success,
}
}
#[test]
fn test_account_meta_data_size() {
let account_meta_data = create_test_account_meta_data();
let size = account_meta_data.try_to_vec().unwrap().len();
assert_eq!(34, size);
}
#[test]
fn test_proposal_instruction_max_size() {
// Arrange
let proposal_instruction = create_test_proposal_instruction();
let size = proposal_instruction.try_to_vec().unwrap().len();
// Act, Assert
assert_eq!(proposal_instruction.get_max_size(), Some(size));
}
#[test]
fn test_empty_proposal_instruction_max_size() {
// Arrange
let mut proposal_instruction = create_test_proposal_instruction();
proposal_instruction.instruction.data = vec![];
proposal_instruction.instruction.accounts = vec![];
let size = proposal_instruction.try_to_vec().unwrap().len();
// Act, Assert
assert_eq!(proposal_instruction.get_max_size(), Some(size));
}
#[test]
fn test_upgrade_instruction_serialization() {
// Arrange
let program_address =
Pubkey::from_str("Hita5Lun87S4MADAF4vGoWEgFm5DyuVqxoWzzqYxS3AD").unwrap();
let buffer_address =
Pubkey::from_str("5XqXkgJGAUwrUHBkxbKpYMGqsRoQLfyqRbYUEkjNY6hL").unwrap();
let governance = Pubkey::from_str("FqSReK9R8QxvFZgdrAwGT3gsYp1ZGfiFjS8xrzyyadn3").unwrap();
let upgrade_instruction = bpf_loader_upgradeable::upgrade(
&program_address,
&buffer_address,
&governance,
&governance,
);
// Act
let instruction_data: InstructionData = upgrade_instruction.clone().into();
let mut instruction_bytes = vec![];
instruction_data.serialize(&mut instruction_bytes).unwrap();
// base64 encoded message is accepted as the input in the UI
let base64 = base64::encode(instruction_bytes.clone());
// Assert
let instruction =
Instruction::from(&InstructionData::deserialize(&mut &instruction_bytes[..]).unwrap());
assert_eq!(upgrade_instruction, instruction);
assert_eq!(base64,"Aqj2kU6IobDiEBU+92OuKwDCuT0WwSTSwFN6EASAAAAHAAAAchkHXTU9jF+rKpILT6dzsVyNI9NsQy9cab+GGvdwNn0AAfh2HVruy2YibpgcQUmJf5att5YdPXSv1k2pRAKAfpSWAAFDVQuXWos2urmegSPblI813GlTm7CJ/8rv+9yzNE3yfwAB3Gw+apCyfrRNqJ6f1160Htkx+uYZT6FIILQ3WzNA4KwAAQan1RcZLFxRIYzJTD1K8X9Y2u4Im6H9ROPb2YoAAAAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAAAA3Gw+apCyfrRNqJ6f1160Htkx+uYZT6FIILQ3WzNA4KwBAAQAAAADAAAA");
}
}

View File

@ -0,0 +1,113 @@
//! Realm Account
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo, program_error::ProgramError, program_pack::IsInitialized,
pubkey::Pubkey,
};
use crate::{
error::GovernanceError,
tools::account::{assert_is_valid_account, get_account_data, AccountMaxSize},
PROGRAM_AUTHORITY_SEED,
};
use crate::state::enums::GovernanceAccountType;
/// Governance Realm Account
/// Account PDA seeds" ['governance', name]
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct Realm {
/// Governance account type
pub account_type: GovernanceAccountType,
/// Community mint
pub community_mint: Pubkey,
/// Reserved space for future versions
pub reserved: [u8; 8],
/// Council mint
pub council_mint: Option<Pubkey>,
/// Governance Realm name
pub name: String,
}
impl AccountMaxSize for Realm {}
impl IsInitialized for Realm {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::Realm
}
}
impl Realm {
/// Asserts the given mint is either Community or Council mint of the Realm
pub fn assert_is_valid_governing_token_mint(
&self,
governing_token_mint: &Pubkey,
) -> Result<(), ProgramError> {
if self.community_mint == *governing_token_mint {
return Ok(());
}
if self.council_mint == Some(*governing_token_mint) {
return Ok(());
}
Err(GovernanceError::InvalidGoverningTokenMint.into())
}
}
/// Checks whether realm account exists, is initialized and owned by Governance program
pub fn assert_is_valid_realm(
program_id: &Pubkey,
realm_info: &AccountInfo,
) -> Result<(), ProgramError> {
assert_is_valid_account(realm_info, GovernanceAccountType::Realm, program_id)
}
/// Deserializes account and checks owner program
pub fn get_realm_data(
program_id: &Pubkey,
realm_info: &AccountInfo,
) -> Result<Realm, ProgramError> {
get_account_data::<Realm>(realm_info, program_id)
}
/// Returns Realm PDA seeds
pub fn get_realm_address_seeds(name: &str) -> [&[u8]; 2] {
[PROGRAM_AUTHORITY_SEED, name.as_bytes()]
}
/// Returns Realm PDA address
pub fn get_realm_address(program_id: &Pubkey, name: &str) -> Pubkey {
Pubkey::find_program_address(&get_realm_address_seeds(name), program_id).0
}
/// Returns Realm Token Holding PDA seeds
pub fn get_governing_token_holding_address_seeds<'a>(
realm: &'a Pubkey,
governing_token_mint: &'a Pubkey,
) -> [&'a [u8]; 3] {
[
PROGRAM_AUTHORITY_SEED,
realm.as_ref(),
governing_token_mint.as_ref(),
]
}
/// Returns Realm Token Holding PDA address
pub fn get_governing_token_holding_address(
program_id: &Pubkey,
realm: &Pubkey,
governing_token_mint: &Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_governing_token_holding_address_seeds(realm, governing_token_mint),
program_id,
)
.0
}

View File

@ -0,0 +1,116 @@
//! Signatory Record
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo, program_error::ProgramError, program_pack::IsInitialized,
pubkey::Pubkey,
};
use crate::{
error::GovernanceError,
tools::account::{get_account_data, AccountMaxSize},
PROGRAM_AUTHORITY_SEED,
};
use crate::state::enums::GovernanceAccountType;
/// Account PDA seeds: ['governance', proposal, signatory]
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct SignatoryRecord {
/// Governance account type
pub account_type: GovernanceAccountType,
/// Proposal the signatory is assigned for
pub proposal: Pubkey,
/// The account of the signatory who can sign off the proposal
pub signatory: Pubkey,
/// Indicates whether the signatory signed off the proposal
pub signed_off: bool,
}
impl AccountMaxSize for SignatoryRecord {}
impl IsInitialized for SignatoryRecord {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::SignatoryRecord
}
}
impl SignatoryRecord {
/// Checks signatory hasn't signed off yet and is transaction signer
pub fn assert_can_sign_off(&self, signatory_info: &AccountInfo) -> Result<(), ProgramError> {
if self.signed_off {
return Err(GovernanceError::SignatoryAlreadySignedOff.into());
}
if !signatory_info.is_signer {
return Err(GovernanceError::SignatoryMustSign.into());
}
Ok(())
}
/// Checks signatory can be removed from Proposal
pub fn assert_can_remove_signatory(&self) -> Result<(), ProgramError> {
if self.signed_off {
return Err(GovernanceError::SignatoryAlreadySignedOff.into());
}
Ok(())
}
}
/// Returns SignatoryRecord PDA seeds
pub fn get_signatory_record_address_seeds<'a>(
proposal: &'a Pubkey,
signatory: &'a Pubkey,
) -> [&'a [u8]; 3] {
[
PROGRAM_AUTHORITY_SEED,
proposal.as_ref(),
signatory.as_ref(),
]
}
/// Returns SignatoryRecord PDA address
pub fn get_signatory_record_address<'a>(
program_id: &Pubkey,
proposal: &'a Pubkey,
signatory: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_signatory_record_address_seeds(proposal, signatory),
program_id,
)
.0
}
/// Deserializes SignatoryRecord account and checks owner program
pub fn get_signatory_record_data(
program_id: &Pubkey,
signatory_record_info: &AccountInfo,
) -> Result<SignatoryRecord, ProgramError> {
get_account_data::<SignatoryRecord>(signatory_record_info, program_id)
}
/// Deserializes SignatoryRecord and validates its PDA
pub fn get_signatory_record_data_for_seeds(
program_id: &Pubkey,
signatory_record_info: &AccountInfo,
proposal: &Pubkey,
signatory: &Pubkey,
) -> Result<SignatoryRecord, ProgramError> {
let (signatory_record_address, _) = Pubkey::find_program_address(
&get_signatory_record_address_seeds(proposal, signatory),
program_id,
);
if signatory_record_address != *signatory_record_info.key {
return Err(GovernanceError::InvalidSignatoryAddress.into());
}
get_signatory_record_data(program_id, signatory_record_info)
}

View File

@ -0,0 +1,198 @@
//! Token Owner Record Account
use crate::{
error::GovernanceError,
tools::account::{get_account_data, AccountMaxSize},
PROGRAM_AUTHORITY_SEED,
};
use crate::state::enums::GovernanceAccountType;
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo, program_error::ProgramError, program_pack::IsInitialized,
pubkey::Pubkey,
};
/// Governance Token Owner Record
/// Account PDA seeds: ['governance', realm, token_mint, token_owner ]
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct TokenOwnerRecord {
/// Governance account type
pub account_type: GovernanceAccountType,
/// The Realm the TokenOwnerRecord belongs to
pub realm: Pubkey,
/// Governing Token Mint the TokenOwnerRecord holds deposit for
pub governing_token_mint: Pubkey,
/// The owner (either single or multisig) of the deposited governing SPL Tokens
/// This is who can authorize a withdrawal of the tokens
pub governing_token_owner: Pubkey,
/// The amount of governing tokens deposited into the Realm
/// This amount is the voter weight used when voting on proposals
pub governing_token_deposit_amount: u64,
/// The number of votes cast by TokenOwner but not relinquished yet
/// Every time a vote is cast this number is increased and it's always decreased when relinquishing a vote regardless of the vote state
pub unrelinquished_votes_count: u32,
/// The total number of votes cast by the TokenOwner
/// If TokenOwner withdraws vote while voting is still in progress total_votes_count is decreased and the vote doesn't count towards the total
pub total_votes_count: u32,
/// Reserved space for future versions
pub reserved: [u8; 8],
/// A single account that is allowed to operate governance with the deposited governing tokens
/// It can be delegated to by the governing_token_owner or current governance_delegate
pub governance_delegate: Option<Pubkey>,
}
impl AccountMaxSize for TokenOwnerRecord {
fn get_max_size(&self) -> Option<usize> {
Some(154)
}
}
impl IsInitialized for TokenOwnerRecord {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::TokenOwnerRecord
}
}
impl TokenOwnerRecord {
/// Checks whether the provided Governance Authority signed transaction
pub fn assert_token_owner_or_delegate_is_signer(
&self,
governance_authority_info: &AccountInfo,
) -> Result<(), ProgramError> {
if governance_authority_info.is_signer {
if &self.governing_token_owner == governance_authority_info.key {
return Ok(());
}
if let Some(governance_delegate) = self.governance_delegate {
if &governance_delegate == governance_authority_info.key {
return Ok(());
}
};
}
Err(GovernanceError::GoverningTokenOwnerOrDelegateMustSign.into())
}
}
/// Returns TokenOwnerRecord PDA address
pub fn get_token_owner_record_address(
program_id: &Pubkey,
realm: &Pubkey,
governing_token_mint: &Pubkey,
governing_token_owner: &Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_token_owner_record_address_seeds(realm, governing_token_mint, governing_token_owner),
program_id,
)
.0
}
/// Returns TokenOwnerRecord PDA seeds
pub fn get_token_owner_record_address_seeds<'a>(
realm: &'a Pubkey,
governing_token_mint: &'a Pubkey,
governing_token_owner: &'a Pubkey,
) -> [&'a [u8]; 4] {
[
PROGRAM_AUTHORITY_SEED,
realm.as_ref(),
governing_token_mint.as_ref(),
governing_token_owner.as_ref(),
]
}
/// Deserializes TokenOwnerRecord account and checks owner program
pub fn get_token_owner_record_data(
program_id: &Pubkey,
token_owner_record_info: &AccountInfo,
) -> Result<TokenOwnerRecord, ProgramError> {
get_account_data::<TokenOwnerRecord>(token_owner_record_info, program_id)
}
/// Deserializes TokenOwnerRecord account and checks its PDA against the provided seeds
pub fn get_token_owner_record_data_for_seeds(
program_id: &Pubkey,
token_owner_record_info: &AccountInfo,
token_owner_record_seeds: &[&[u8]],
) -> Result<TokenOwnerRecord, ProgramError> {
let (token_owner_record_address, _) =
Pubkey::find_program_address(token_owner_record_seeds, program_id);
if token_owner_record_address != *token_owner_record_info.key {
return Err(GovernanceError::InvalidTokenOwnerRecordAccountAddress.into());
}
get_token_owner_record_data(program_id, token_owner_record_info)
}
/// Deserializes TokenOwnerRecord account and checks that its PDA matches the given realm and governing mint
pub fn get_token_owner_record_data_for_realm_and_governing_mint(
program_id: &Pubkey,
token_owner_record_info: &AccountInfo,
realm: &Pubkey,
governing_token_mint: &Pubkey,
) -> Result<TokenOwnerRecord, ProgramError> {
let token_owner_record_data = get_token_owner_record_data(program_id, token_owner_record_info)?;
if token_owner_record_data.governing_token_mint != *governing_token_mint {
return Err(GovernanceError::InvalidGoverningMintForTokenOwnerRecord.into());
}
if token_owner_record_data.realm != *realm {
return Err(GovernanceError::InvalidRealmForTokenOwnerRecord.into());
}
Ok(token_owner_record_data)
}
/// Deserializes TokenOwnerRecord account and checks its address is the give proposal_owner
pub fn get_token_owner_record_data_for_proposal_owner(
program_id: &Pubkey,
token_owner_record_info: &AccountInfo,
proposal_owner: &Pubkey,
) -> Result<TokenOwnerRecord, ProgramError> {
if token_owner_record_info.key != proposal_owner {
return Err(GovernanceError::InvalidProposalOwnerAccount.into());
}
get_token_owner_record_data(program_id, token_owner_record_info)
}
#[cfg(test)]
mod test {
use solana_program::borsh::get_packed_len;
use super::*;
#[test]
fn test_max_size() {
let token_owner_record = TokenOwnerRecord {
account_type: GovernanceAccountType::TokenOwnerRecord,
realm: Pubkey::new_unique(),
governing_token_mint: Pubkey::new_unique(),
governing_token_owner: Pubkey::new_unique(),
governing_token_deposit_amount: 10,
governance_delegate: Some(Pubkey::new_unique()),
unrelinquished_votes_count: 1,
total_votes_count: 1,
reserved: [0; 8],
};
let size = get_packed_len::<TokenOwnerRecord>();
assert_eq!(token_owner_record.get_max_size(), Some(size));
}
}

View File

@ -0,0 +1,104 @@
//! Proposal Vote Record Account
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::account_info::AccountInfo;
use solana_program::program_error::ProgramError;
use solana_program::{program_pack::IsInitialized, pubkey::Pubkey};
use crate::error::GovernanceError;
use crate::tools::account::get_account_data;
use crate::{tools::account::AccountMaxSize, PROGRAM_AUTHORITY_SEED};
use crate::state::enums::{GovernanceAccountType, VoteWeight};
/// Proposal VoteRecord
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub struct VoteRecord {
/// Governance account type
pub account_type: GovernanceAccountType,
/// Proposal account
pub proposal: Pubkey,
/// The user who casted this vote
/// This is the Governing Token Owner who deposited governing tokens into the Realm
pub governing_token_owner: Pubkey,
/// Indicates whether the vote was relinquished by voter
pub is_relinquished: bool,
/// Voter's vote: Yes/No and amount
pub vote_weight: VoteWeight,
}
impl AccountMaxSize for VoteRecord {}
impl IsInitialized for VoteRecord {
fn is_initialized(&self) -> bool {
self.account_type == GovernanceAccountType::VoteRecord
}
}
impl VoteRecord {
/// Checks the vote can be relinquished
pub fn assert_can_relinquish_vote(&self) -> Result<(), ProgramError> {
if self.is_relinquished {
return Err(GovernanceError::VoteAlreadyRelinquished.into());
}
Ok(())
}
}
/// Deserializes VoteRecord account and checks owner program
pub fn get_vote_record_data(
program_id: &Pubkey,
vote_record_info: &AccountInfo,
) -> Result<VoteRecord, ProgramError> {
get_account_data::<VoteRecord>(vote_record_info, program_id)
}
/// Deserializes VoteRecord and checks it belongs to the provided Proposal and Governing Token Owner
pub fn get_vote_record_data_for_proposal_and_token_owner(
program_id: &Pubkey,
vote_record_info: &AccountInfo,
proposal: &Pubkey,
governing_token_owner: &Pubkey,
) -> Result<VoteRecord, ProgramError> {
let vote_record_data = get_vote_record_data(program_id, vote_record_info)?;
if vote_record_data.proposal != *proposal {
return Err(GovernanceError::InvalidProposalForVoterRecord.into());
}
if vote_record_data.governing_token_owner != *governing_token_owner {
return Err(GovernanceError::InvalidGoverningTokenOwnerForVoteRecord.into());
}
Ok(vote_record_data)
}
/// Returns VoteRecord PDA seeds
pub fn get_vote_record_address_seeds<'a>(
proposal: &'a Pubkey,
token_owner_record: &'a Pubkey,
) -> [&'a [u8]; 3] {
[
PROGRAM_AUTHORITY_SEED,
proposal.as_ref(),
token_owner_record.as_ref(),
]
}
/// Returns VoteRecord PDA address
pub fn get_vote_record_address<'a>(
program_id: &Pubkey,
proposal: &'a Pubkey,
token_owner_record: &'a Pubkey,
) -> Pubkey {
Pubkey::find_program_address(
&get_vote_record_address_seeds(proposal, token_owner_record),
program_id,
)
.0
}

View File

@ -0,0 +1,144 @@
//! General purpose account utility functions
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::AccountInfo, borsh::try_from_slice_unchecked, msg, program::invoke_signed,
program_error::ProgramError, program_pack::IsInitialized, pubkey::Pubkey, rent::Rent,
system_instruction::create_account,
};
use crate::error::GovernanceError;
/// Trait for accounts to return their max size
pub trait AccountMaxSize {
/// Returns max account size or None if max size is not known and actual instance size should be used
fn get_max_size(&self) -> Option<usize> {
None
}
}
/// Creates a new account and serializes data into it using the provided seeds to invoke signed CPI call
/// Note: This functions also checks the provided account PDA matches the supplied seeds
pub fn create_and_serialize_account_signed<'a, T: BorshSerialize + AccountMaxSize>(
payer_info: &AccountInfo<'a>,
account_info: &AccountInfo<'a>,
account_data: &T,
account_address_seeds: &[&[u8]],
program_id: &Pubkey,
system_info: &AccountInfo<'a>,
rent: &Rent,
) -> Result<(), ProgramError> {
// Get PDA and assert it's the same as the requested account address
let (account_address, bump_seed) =
Pubkey::find_program_address(account_address_seeds, program_id);
if account_address != *account_info.key {
msg!(
"Create account with PDA: {:?} was requested while PDA: {:?} was expected",
account_info.key,
account_address
);
return Err(ProgramError::InvalidSeeds);
}
let (serialized_data, account_size) = if let Some(max_size) = account_data.get_max_size() {
(None, max_size)
} else {
let serialized_data = account_data.try_to_vec()?;
let account_size = serialized_data.len();
(Some(serialized_data), account_size)
};
let create_account_instruction = create_account(
payer_info.key,
account_info.key,
rent.minimum_balance(account_size),
account_size as u64,
program_id,
);
let mut signers_seeds = account_address_seeds.to_vec();
let bump = &[bump_seed];
signers_seeds.push(bump);
invoke_signed(
&create_account_instruction,
&[
payer_info.clone(),
account_info.clone(),
system_info.clone(),
],
&[&signers_seeds[..]],
)?;
if let Some(serialized_data) = serialized_data {
account_info
.data
.borrow_mut()
.copy_from_slice(&serialized_data);
} else {
account_data.serialize(&mut *account_info.data.borrow_mut())?;
}
Ok(())
}
/// Deserializes account and checks it's initialized and owned by the specified program
pub fn get_account_data<T: BorshDeserialize + IsInitialized>(
account_info: &AccountInfo,
owner_program_id: &Pubkey,
) -> Result<T, ProgramError> {
if account_info.data_is_empty() {
return Err(GovernanceError::AccountDoesNotExist.into());
}
if account_info.owner != owner_program_id {
return Err(GovernanceError::InvalidAccountOwner.into());
}
let account: T = try_from_slice_unchecked(&account_info.data.borrow())?;
if !account.is_initialized() {
Err(ProgramError::UninitializedAccount)
} else {
Ok(account)
}
}
/// Asserts the given account is not empty, owned by the given program and of the expected type
/// Note: The function assumes the account type T is stored as the first element in the account data
pub fn assert_is_valid_account<T: BorshDeserialize + PartialEq>(
account_info: &AccountInfo,
expected_account_type: T,
owner_program_id: &Pubkey,
) -> Result<(), ProgramError> {
if account_info.owner != owner_program_id {
return Err(GovernanceError::InvalidAccountOwner.into());
}
if account_info.data_is_empty() {
return Err(GovernanceError::AccountDoesNotExist.into());
}
let account_type: T = try_from_slice_unchecked(&account_info.data.borrow())?;
if account_type != expected_account_type {
return Err(GovernanceError::InvalidAccountType.into());
};
Ok(())
}
/// Disposes account by transferring its lamports to the beneficiary account and zeros its data
// After transaction completes the runtime would remove the account with no lamports
pub fn dispose_account(account_info: &AccountInfo, beneficiary_info: &AccountInfo) {
let account_lamports = account_info.lamports();
**account_info.lamports.borrow_mut() = 0;
**beneficiary_info.lamports.borrow_mut() = beneficiary_info
.lamports()
.checked_add(account_lamports)
.unwrap();
let mut account_data = account_info.data.borrow_mut();
account_data.fill(0);
}

View File

@ -0,0 +1,96 @@
//! General purpose bpf_loader_upgradeable utility functions
use solana_program::{
account_info::AccountInfo,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
program::invoke,
program_error::ProgramError,
pubkey::Pubkey,
};
use bincode::deserialize;
use crate::error::GovernanceError;
/// Returns ProgramData account address for the given Program
pub fn get_program_data_address(program: &Pubkey) -> Pubkey {
Pubkey::find_program_address(&[program.as_ref()], &bpf_loader_upgradeable::id()).0
}
/// Returns upgrade_authority from the given Upgradable Loader Account
pub fn get_program_upgrade_authority(
upgradable_loader_state: &UpgradeableLoaderState,
) -> Result<Option<Pubkey>, ProgramError> {
let upgrade_authority = match upgradable_loader_state {
UpgradeableLoaderState::ProgramData {
slot: _,
upgrade_authority_address,
} => *upgrade_authority_address,
_ => return Err(ProgramError::InvalidAccountData),
};
Ok(upgrade_authority)
}
/// Sets new upgrade authority for the given upgradable program
pub fn set_program_upgrade_authority<'a>(
program_address: &Pubkey,
program_data_info: &AccountInfo<'a>,
program_upgrade_authority_info: &AccountInfo<'a>,
new_authority_info: &AccountInfo<'a>,
bpf_upgrade_loader_info: &AccountInfo<'a>,
) -> Result<(), ProgramError> {
let set_upgrade_authority_instruction = bpf_loader_upgradeable::set_upgrade_authority(
program_address,
program_upgrade_authority_info.key,
Some(new_authority_info.key),
);
invoke(
&set_upgrade_authority_instruction,
&[
program_data_info.clone(),
program_upgrade_authority_info.clone(),
bpf_upgrade_loader_info.clone(),
new_authority_info.clone(),
],
)
}
/// Asserts the program is upgradable and its upgrade authority is a signer of the transaction
pub fn assert_program_upgrade_authority_is_signer(
program_address: &Pubkey,
program_data_info: &AccountInfo,
program_upgrade_authority_info: &AccountInfo,
) -> Result<(), ProgramError> {
if program_data_info.owner != &bpf_loader_upgradeable::id() {
return Err(ProgramError::IncorrectProgramId);
}
let program_data_address = get_program_data_address(program_address);
if program_data_address != *program_data_info.key {
return Err(GovernanceError::InvalidProgramDataAccountAddress.into());
}
let upgrade_authority = if let UpgradeableLoaderState::ProgramData {
slot: _,
upgrade_authority_address,
} = deserialize(&program_data_info.data.borrow())
.map_err(|_| GovernanceError::InvalidProgramDataAccountData)?
{
upgrade_authority_address
} else {
None
};
let upgrade_authority = upgrade_authority.ok_or(GovernanceError::ProgramNotUpgradable)?;
if upgrade_authority != *program_upgrade_authority_info.key {
return Err(GovernanceError::InvalidUpgradeAuthority.into());
}
if !program_upgrade_authority_info.is_signer {
return Err(GovernanceError::UpgradeAuthorityMustSign.into());
}
Ok(())
}

View File

@ -0,0 +1,9 @@
//! Utility functions
pub mod account;
pub mod spl_token;
pub mod bpf_loader_upgradeable;
pub mod pack;

View File

@ -0,0 +1,14 @@
//! General purpose packing utility functions
use arrayref::array_refs;
use solana_program::{program_error::ProgramError, program_option::COption, pubkey::Pubkey};
/// Unpacks COption from a slice
pub fn unpack_coption_pubkey(src: &[u8; 36]) -> Result<COption<Pubkey>, ProgramError> {
let (tag, body) = array_refs![src, 4, 32];
match *tag {
[0, 0, 0, 0] => Ok(COption::None),
[1, 0, 0, 0] => Ok(COption::Some(Pubkey::new_from_array(*body))),
_ => Err(ProgramError::InvalidAccountData),
}
}

View File

@ -0,0 +1,373 @@
//! General purpose SPL token utility functions
use arrayref::array_ref;
use solana_program::{
account_info::AccountInfo,
entrypoint::ProgramResult,
msg,
program::{invoke, invoke_signed},
program_error::ProgramError,
program_option::COption,
program_pack::Pack,
pubkey::Pubkey,
rent::Rent,
system_instruction,
};
use spl_token::{
instruction::set_authority,
state::{Account, Mint},
};
use crate::{error::GovernanceError, tools::pack::unpack_coption_pubkey};
/// Creates and initializes SPL token account with PDA using the provided PDA seeds
#[allow(clippy::too_many_arguments)]
pub fn create_spl_token_account_signed<'a>(
payer_info: &AccountInfo<'a>,
token_account_info: &AccountInfo<'a>,
token_account_address_seeds: &[&[u8]],
token_mint_info: &AccountInfo<'a>,
token_account_owner_info: &AccountInfo<'a>,
program_id: &Pubkey,
system_info: &AccountInfo<'a>,
spl_token_info: &AccountInfo<'a>,
rent_sysvar_info: &AccountInfo<'a>,
rent: &Rent,
) -> Result<(), ProgramError> {
let create_account_instruction = system_instruction::create_account(
payer_info.key,
token_account_info.key,
1.max(rent.minimum_balance(spl_token::state::Account::get_packed_len())),
spl_token::state::Account::get_packed_len() as u64,
&spl_token::id(),
);
let (account_address, bump_seed) =
Pubkey::find_program_address(token_account_address_seeds, program_id);
if account_address != *token_account_info.key {
msg!(
"Create SPL Token Account with PDA: {:?} was requested while PDA: {:?} was expected",
token_account_info.key,
account_address
);
return Err(ProgramError::InvalidSeeds);
}
let mut signers_seeds = token_account_address_seeds.to_vec();
let bump = &[bump_seed];
signers_seeds.push(bump);
invoke_signed(
&create_account_instruction,
&[
payer_info.clone(),
token_account_info.clone(),
system_info.clone(),
],
&[&signers_seeds[..]],
)?;
let initialize_account_instruction = spl_token::instruction::initialize_account(
&spl_token::id(),
token_account_info.key,
token_mint_info.key,
token_account_owner_info.key,
)?;
invoke(
&initialize_account_instruction,
&[
payer_info.clone(),
token_account_info.clone(),
token_account_owner_info.clone(),
token_mint_info.clone(),
spl_token_info.clone(),
rent_sysvar_info.clone(),
],
)?;
Ok(())
}
/// Transfers SPL Tokens
pub fn transfer_spl_tokens<'a>(
source_info: &AccountInfo<'a>,
destination_info: &AccountInfo<'a>,
authority_info: &AccountInfo<'a>,
amount: u64,
spl_token_info: &AccountInfo<'a>,
) -> ProgramResult {
let transfer_instruction = spl_token::instruction::transfer(
&spl_token::id(),
source_info.key,
destination_info.key,
authority_info.key,
&[],
amount,
)
.unwrap();
invoke(
&transfer_instruction,
&[
spl_token_info.clone(),
authority_info.clone(),
source_info.clone(),
destination_info.clone(),
],
)?;
Ok(())
}
/// Transfers SPL Tokens from a token account owned by the provided PDA authority with seeds
pub fn transfer_spl_tokens_signed<'a>(
source_info: &AccountInfo<'a>,
destination_info: &AccountInfo<'a>,
authority_info: &AccountInfo<'a>,
authority_seeds: &[&[u8]],
program_id: &Pubkey,
amount: u64,
spl_token_info: &AccountInfo<'a>,
) -> ProgramResult {
let (authority_address, bump_seed) = Pubkey::find_program_address(authority_seeds, program_id);
if authority_address != *authority_info.key {
msg!(
"Transfer SPL Token with Authority PDA: {:?} was requested while PDA: {:?} was expected",
authority_info.key,
authority_address
);
return Err(ProgramError::InvalidSeeds);
}
let transfer_instruction = spl_token::instruction::transfer(
&spl_token::id(),
source_info.key,
destination_info.key,
authority_info.key,
&[],
amount,
)
.unwrap();
let mut signers_seeds = authority_seeds.to_vec();
let bump = &[bump_seed];
signers_seeds.push(bump);
invoke_signed(
&transfer_instruction,
&[
spl_token_info.clone(),
authority_info.clone(),
source_info.clone(),
destination_info.clone(),
],
&[&signers_seeds[..]],
)?;
Ok(())
}
/// Asserts the given account_info represents a valid SPL Token account which is initialized and belongs to spl_token program
pub fn assert_is_valid_spl_token_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
if account_info.data_is_empty() {
return Err(GovernanceError::SplTokenAccountDoesNotExist.into());
}
if account_info.owner != &spl_token::id() {
return Err(GovernanceError::SplTokenAccountWithInvalidOwner.into());
}
if account_info.data_len() != Account::LEN {
return Err(GovernanceError::SplTokenInvalidTokenAccountData.into());
}
// TokeAccount layout: mint(32), owner(32), amount(8), delegate(36), state(1), ...
let data = account_info.try_borrow_data()?;
let state = array_ref![data, 108, 1];
if state == &[0] {
return Err(GovernanceError::SplTokenAccountNotInitialized.into());
}
Ok(())
}
/// Asserts the given mint_info represents a valid SPL Token Mint account which is initialized and belongs to spl_token program
pub fn assert_is_valid_spl_token_mint(mint_info: &AccountInfo) -> Result<(), ProgramError> {
if mint_info.data_is_empty() {
return Err(GovernanceError::SplTokenMintDoesNotExist.into());
}
if mint_info.owner != &spl_token::id() {
return Err(GovernanceError::SplTokenMintWithInvalidOwner.into());
}
if mint_info.data_len() != Mint::LEN {
return Err(GovernanceError::SplTokenInvalidMintAccountData.into());
}
// In token program [36, 8, 1, is_initialized(1), 36] is the layout
let data = mint_info.try_borrow_data().unwrap();
let is_initialized = array_ref![data, 45, 1];
if is_initialized == &[0] {
return Err(GovernanceError::SplTokenMintNotInitialized.into());
}
Ok(())
}
/// Computationally cheap method to get amount from a token account
/// It reads amount without deserializing full account data
pub fn get_spl_token_amount(token_account_info: &AccountInfo) -> Result<u64, ProgramError> {
assert_is_valid_spl_token_account(token_account_info)?;
// TokeAccount layout: mint(32), owner(32), amount(8), ...
let data = token_account_info.try_borrow_data()?;
let amount = array_ref![data, 64, 8];
Ok(u64::from_le_bytes(*amount))
}
/// Computationally cheap method to get mint from a token account
/// It reads mint without deserializing full account data
pub fn get_spl_token_mint(token_account_info: &AccountInfo) -> Result<Pubkey, ProgramError> {
assert_is_valid_spl_token_account(token_account_info)?;
// TokeAccount layout: mint(32), owner(32), amount(8), ...
let data = token_account_info.try_borrow_data()?;
let mint_data = array_ref![data, 0, 32];
Ok(Pubkey::new_from_array(*mint_data))
}
/// Computationally cheap method to get owner from a token account
/// It reads owner without deserializing full account data
pub fn get_spl_token_owner(token_account_info: &AccountInfo) -> Result<Pubkey, ProgramError> {
assert_is_valid_spl_token_account(token_account_info)?;
// TokeAccount layout: mint(32), owner(32), amount(8)
let data = token_account_info.try_borrow_data()?;
let owner_data = array_ref![data, 32, 32];
Ok(Pubkey::new_from_array(*owner_data))
}
/// Computationally cheap method to just get supply from a mint without unpacking the whole object
pub fn get_spl_token_mint_supply(mint_info: &AccountInfo) -> Result<u64, ProgramError> {
assert_is_valid_spl_token_mint(mint_info)?;
// In token program, 36, 8, 1, 1 is the layout, where the first 8 is supply u64.
// so we start at 36.
let data = mint_info.try_borrow_data().unwrap();
let bytes = array_ref![data, 36, 8];
Ok(u64::from_le_bytes(*bytes))
}
/// Computationally cheap method to just get authority from a mint without unpacking the whole object
pub fn get_spl_token_mint_authority(
mint_info: &AccountInfo,
) -> Result<COption<Pubkey>, ProgramError> {
assert_is_valid_spl_token_mint(mint_info)?;
// In token program, 36, 8, 1, 1 is the layout, where the first 36 is authority.
let data = mint_info.try_borrow_data().unwrap();
let bytes = array_ref![data, 0, 36];
unpack_coption_pubkey(bytes)
}
/// Asserts current mint authority matches the given authority and it's signer of the transaction
pub fn assert_spl_token_mint_authority_is_signer(
mint_info: &AccountInfo,
mint_authority_info: &AccountInfo,
) -> Result<(), ProgramError> {
let mint_authority = get_spl_token_mint_authority(mint_info)?;
if mint_authority.is_none() {
return Err(GovernanceError::MintHasNoAuthority.into());
}
if !mint_authority.contains(mint_authority_info.key) {
return Err(GovernanceError::InvalidMintAuthority.into());
}
if !mint_authority_info.is_signer {
return Err(GovernanceError::MintAuthorityMustSign.into());
}
Ok(())
}
/// Sets new mint authority
pub fn set_spl_token_mint_authority<'a>(
mint_info: &AccountInfo<'a>,
mint_authority: &AccountInfo<'a>,
new_mint_authority: &Pubkey,
spl_token_info: &AccountInfo<'a>,
) -> Result<(), ProgramError> {
let set_authority_ix = set_authority(
&spl_token::id(),
mint_info.key,
Some(new_mint_authority),
spl_token::instruction::AuthorityType::MintTokens,
mint_authority.key,
&[],
)?;
invoke(
&set_authority_ix,
&[
mint_info.clone(),
mint_authority.clone(),
spl_token_info.clone(),
],
)?;
Ok(())
}
/// Asserts current token owner matches the given owner and it's signer of the transaction
pub fn assert_spl_token_owner_is_signer(
token_info: &AccountInfo,
token_owner_info: &AccountInfo,
) -> Result<(), ProgramError> {
let token_owner = get_spl_token_owner(token_info)?;
if token_owner != *token_owner_info.key {
return Err(GovernanceError::InvalidTokenOwner.into());
}
if !token_owner_info.is_signer {
return Err(GovernanceError::TokenOwnerMustSign.into());
}
Ok(())
}
/// Sets new token account owner
pub fn set_spl_token_owner<'a>(
token_info: &AccountInfo<'a>,
token_owner: &AccountInfo<'a>,
new_token_owner: &Pubkey,
spl_token_info: &AccountInfo<'a>,
) -> Result<(), ProgramError> {
let set_authority_ix = set_authority(
&spl_token::id(),
token_info.key,
Some(new_token_owner),
spl_token::instruction::AuthorityType::AccountOwner,
token_owner.key,
&[],
)?;
invoke(
&set_authority_ix,
&[
token_info.clone(),
token_owner.clone(),
spl_token_info.clone(),
],
)?;
Ok(())
}

View File

@ -0,0 +1 @@
!*.so

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More