Port SPL to solana-program and `cargo build-bpf`
This commit is contained in:
parent
4616c2eb0f
commit
80e29ef6b9
|
@ -5,3 +5,5 @@ bin
|
|||
config.json
|
||||
node_modules
|
||||
./package-lock.json
|
||||
*.so
|
||||
*-dump.txt
|
||||
|
|
|
@ -20,7 +20,7 @@ services:
|
|||
env:
|
||||
global:
|
||||
- RUST_BACKTRACE=1
|
||||
- SOLANA_VERSION=v1.4.2
|
||||
- SOLANA_VERSION=v1.4.3
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
|
|
@ -22,5 +22,6 @@ node --version
|
|||
if [[ -n $SOLANA_VERSION ]]; then
|
||||
sh -c "$(curl -sSfL https://release.solana.com/$SOLANA_VERSION/install)"
|
||||
fi
|
||||
PATH="~/.local/share/solana/install/active_release/bin:$PATH"
|
||||
export PATH="~/.local/share/solana/install/active_release/bin:$PATH"
|
||||
solana --version
|
||||
cargo build-bpf --version
|
||||
|
|
File diff suppressed because it is too large
Load Diff
22
Cargo.toml
22
Cargo.toml
|
@ -5,33 +5,17 @@ members = [
|
|||
"memo/program",
|
||||
"shared-memory/program",
|
||||
"stake-pool/program",
|
||||
"themis/program_bn",
|
||||
"themis/program_ristretto",
|
||||
"token-lending/program",
|
||||
"token-swap/program",
|
||||
"token/cli",
|
||||
"token/program",
|
||||
"token/program-v3",
|
||||
"themis/program_bn",
|
||||
"themis/program_ristretto",
|
||||
]
|
||||
exclude = [
|
||||
"shared-memory/client",
|
||||
"token/perf-monitor",
|
||||
"themis/client_bn",
|
||||
"themis/client_ristretto",
|
||||
"token/perf-monitor",
|
||||
]
|
||||
|
||||
# Workflow for developing against local Solana crates
|
||||
#
|
||||
# 0. Uncomment the below patches
|
||||
# 1. Replace PATH_TO_SOLANA with your local filestem path to the Solana mono-repo
|
||||
# 2. Run `cargo update`
|
||||
# 3. Use `cargo` normally
|
||||
#
|
||||
|
||||
#[patch.crates-io]
|
||||
#solana-account-decoder = {path = "PATH_TO_SOLANA/account-decoder" }
|
||||
#solana-clap-utils = {path = "PATH_TO_SOLANA/clap-utils" }
|
||||
#solana-cli-config = {path = "PATH_TO_SOLANA/cli-config" }
|
||||
#solana-client = { path = "PATH_TO_SOLANA/client"}
|
||||
#solana-logger = {path = "PATH_TO_SOLANA/logger" }
|
||||
#solana-sdk = { path = "PATH_TO_SOLANA/sdk" }
|
||||
|
|
63
README.md
63
README.md
|
@ -16,55 +16,54 @@ all implementations.
|
|||
|
||||
Full documentation is available at https://spl.solana.com
|
||||
|
||||
## Building
|
||||
## Development
|
||||
|
||||
These programs cannot be built directly via cargo and instead require the build
|
||||
scripts located in Solana's BPF-SDK.
|
||||
### Environment Setup
|
||||
|
||||
Download or update the BPF-SDK by running:
|
||||
```bash
|
||||
$ ./do.sh update
|
||||
1. Install the latest Rust stable from https://rustup.rs/
|
||||
2. Install the latest Solana command-line tools from https://docs.solana.com/cli/install-solana-cli-tools
|
||||
|
||||
### Build
|
||||
|
||||
The normal cargo build is available for building programs against your host machine:
|
||||
```
|
||||
$ cargo build
|
||||
```
|
||||
|
||||
To build all programs, run:
|
||||
```bash
|
||||
$ ./do.sh build all
|
||||
To build a specific program, such as SPL Token, for the Solana BPF target:
|
||||
```
|
||||
$ cd token/program
|
||||
$ cargo build-bpf
|
||||
```
|
||||
|
||||
Or choose a specific program:
|
||||
### Test
|
||||
|
||||
Unit tests contained within all projects can be run with:
|
||||
```bash
|
||||
$ ./do.sh build <program>
|
||||
$ cargo test
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Unit tests contained within all projects can be built via:
|
||||
```bash
|
||||
$ ./do.sh test all
|
||||
To run a specific program's tests, such as SPL Token:
|
||||
```
|
||||
$ cd token/program
|
||||
$ cargo test
|
||||
```
|
||||
|
||||
Or:
|
||||
```bash
|
||||
$ ./do.sh test <program>
|
||||
```
|
||||
|
||||
End-to-end testing may be performed via the per-project .js bindings. See the
|
||||
Integration testing may be performed via the per-project .js bindings. See the
|
||||
[token program's js project](token/js) for an example.
|
||||
|
||||
## Clippy
|
||||
|
||||
Clippy is also supported via:
|
||||
### Clippy
|
||||
```bash
|
||||
$ ./do.sh clippy all
|
||||
$ cargo clippy
|
||||
```
|
||||
|
||||
Or:
|
||||
```
|
||||
$ ./do.sh clippy <program>
|
||||
### Coverage
|
||||
```bash
|
||||
$ ./coverage.sh
|
||||
```
|
||||
|
||||
|
||||
## Release Process
|
||||
|
||||
SPL programs are currently tagged and released manually. Each program is
|
||||
versioned independently of the others, with all new development occurring on
|
||||
master. Once a program is tested and deemed ready for release:
|
||||
|
@ -73,7 +72,9 @@ master. Once a program is tested and deemed ready for release:
|
|||
|
||||
* Increment the version number in the program's Cargo.toml
|
||||
* Generate a new program ID and replace in `<program>/program-id.md` and `<program>/src/lib.rs`
|
||||
* Run `./do.sh build <program>` to update relevant C bindings. (Note the location of the generated `spl_<program>.so` for attaching to the Github release.)
|
||||
* Run `cargo build <program>` to update relevant C bindings. (Note the
|
||||
location of the generated `spl_<program>.so` for attaching to the Github
|
||||
release.)
|
||||
* Open a PR with these version changes and merge after passing CI.
|
||||
|
||||
### Create Github tag
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
channel=${1:-v1.3.17}
|
||||
installDir="$(dirname "$0")"/bin
|
||||
cacheDir=~/.cache/solana-bpf-sdk/"$channel"
|
||||
|
||||
echo "Installing $channel BPF SDK into $installDir"
|
||||
|
||||
set -x
|
||||
|
||||
if [[ ! -r "$cacheDir"/bpf-sdk.tar.bz2 ]]; then
|
||||
mkdir -p "$cacheDir"
|
||||
curl -L --retry 5 --retry-delay 2 -o "$cacheDir"/bpf-sdk.tar.bz2 \
|
||||
https://solana-sdk.s3.amazonaws.com/"$channel"/bpf-sdk.tar.bz2
|
||||
fi
|
||||
|
||||
rm -rf "$installDir"
|
||||
mkdir -p "$installDir"
|
||||
(
|
||||
cd "$installDir"
|
||||
tar jxf "$cacheDir"/bpf-sdk.tar.bz2
|
||||
)
|
||||
cat "$installDir"/bpf-sdk/version.txt
|
20
ci/script.sh
20
ci/script.sh
|
@ -34,14 +34,11 @@ export RUSTFLAGS="-D warnings"
|
|||
export RUSTBACKTRACE=1
|
||||
|
||||
_ cargo fmt --all -- --check
|
||||
_ cargo +nightly clippy --workspace --all-targets -- --deny=warnings
|
||||
|
||||
|
||||
# Build client libraries
|
||||
_ cargo +nightly clippy -Zunstable-options --workspace --all-targets -- --deny=warnings
|
||||
_ cargo build
|
||||
_ cargo test
|
||||
_ cargo run --manifest-path=utils/test-client/Cargo.toml
|
||||
|
||||
|
||||
# # Check generated C headers
|
||||
# _ cargo run --manifest-path=utils/cgen/Cargo.toml
|
||||
#
|
||||
|
@ -50,20 +47,11 @@ _ cargo run --manifest-path=utils/test-client/Cargo.toml
|
|||
# _ git diff --exit-code token-swap/program/inc/token-swap.h
|
||||
# _ cc token-swap/program/inc/token-swap.h -o target/token-swap.gch
|
||||
|
||||
|
||||
# For all BPF programs
|
||||
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
|
||||
program_dir=$(dirname "$Xargo_toml")
|
||||
(
|
||||
# Run clippy for all program crates, with the `program` feature enabled
|
||||
cd $program_dir
|
||||
_ cargo +nightly clippy --features=program -- --deny=warnings
|
||||
)
|
||||
|
||||
_ ./do.sh build "$program_dir"
|
||||
|
||||
_ ./do.sh test "$program_dir"
|
||||
|
||||
_ ./do.sh dump "$program_dir"
|
||||
_ cargo build-bpf --manifest-path="$program_dir"/Cargo.toml --dump
|
||||
done
|
||||
|
||||
# Run client tests
|
||||
|
|
|
@ -56,7 +56,7 @@ for program in ${programs[@]}; do
|
|||
(
|
||||
set -ex
|
||||
cd $program
|
||||
cargo +nightly test --target-dir $here/target/cov --features=program
|
||||
cargo +nightly test --target-dir $here/target/cov
|
||||
)
|
||||
done
|
||||
|
||||
|
|
212
do.sh
212
do.sh
|
@ -1,212 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CALLER_PWD=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: do.sh <action> <project> <action specific arguments>
|
||||
Supported actions:
|
||||
build
|
||||
build-lib
|
||||
clean
|
||||
clippy
|
||||
doc
|
||||
dump
|
||||
fmt
|
||||
test
|
||||
update
|
||||
Supported projects:
|
||||
all
|
||||
any directory containing a Cargo.toml file
|
||||
EOF
|
||||
}
|
||||
|
||||
sdkDir=bin/bpf-sdk
|
||||
profile=bpfel-unknown-unknown/release
|
||||
|
||||
readCargoVariable() {
|
||||
declare variable="$1"
|
||||
declare Cargo_toml="$2"
|
||||
|
||||
while read -r name equals value _; do
|
||||
if [[ $name = "$variable" && $equals = = ]]; then
|
||||
echo "${value//\"/}"
|
||||
return
|
||||
fi
|
||||
done < <(cat "$Cargo_toml")
|
||||
echo "Unable to locate $variable in $Cargo_toml" 1>&2
|
||||
}
|
||||
|
||||
perform_action() {
|
||||
set -e
|
||||
# Use relative path if arg starts with "."
|
||||
if [[ $2 == .* ]]; then
|
||||
projectDir="$CALLER_PWD"/$2
|
||||
else
|
||||
projectDir="$PWD"/$2
|
||||
fi
|
||||
targetDir="$PWD"/target
|
||||
features=
|
||||
|
||||
crateName="$(readCargoVariable name "$projectDir/Cargo.toml")"
|
||||
so_path="$targetDir/$profile"
|
||||
so_name="${crateName//\-/_}"
|
||||
so_name_unstripped="${so_name}_unstripped"
|
||||
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
features="--features=program"
|
||||
fi
|
||||
case "$1" in
|
||||
build)
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
echo "build $crateName ($projectDir)"
|
||||
"$sdkDir"/rust/build.sh "$projectDir"
|
||||
cp "$so_path/${so_name}.so" "$so_path/${so_name_unstripped}.so"
|
||||
"$sdkDir"/dependencies/llvm-native/bin/llvm-objcopy --strip-all "$so_path/${so_name}.so" "$so_path/${so_name}.so"
|
||||
else
|
||||
echo "$projectDir does not contain a program, skipping"
|
||||
fi
|
||||
;;
|
||||
build-lib)
|
||||
(
|
||||
cd "$projectDir"
|
||||
echo "build-lib $crateName ($projectDir)"
|
||||
export RUSTFLAGS="${@:3}"
|
||||
cargo build
|
||||
)
|
||||
;;
|
||||
clean)
|
||||
"$sdkDir"/rust/clean.sh "$projectDir"
|
||||
;;
|
||||
clippy)
|
||||
(
|
||||
cd "$projectDir"
|
||||
echo "clippy $crateName ($projectDir)"
|
||||
cargo +nightly clippy $features ${@:3}
|
||||
)
|
||||
;;
|
||||
doc)
|
||||
(
|
||||
cd "$projectDir"
|
||||
echo "generating docs $crateName ($projectDir)"
|
||||
cargo doc ${@:3}
|
||||
)
|
||||
;;
|
||||
dump)
|
||||
# Dump depends on tools that are not installed by default and must be installed manually
|
||||
# - readelf
|
||||
# - rustfilt
|
||||
if [[ -f "$projectDir"/Xargo.toml ]]; then
|
||||
if ! which rustfilt > /dev/null; then
|
||||
echo "Error: rustfilt not found. It can be installed by running: cargo install rustfilt"
|
||||
exit 1
|
||||
fi
|
||||
if ! which readelf > /dev/null; then
|
||||
if [[ $(uname) = Darwin ]]; then
|
||||
echo "Error: readelf not found. It can be installed by running: brew install binutils"
|
||||
else
|
||||
echo "Error: readelf not found."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$CALLER_PWD"
|
||||
"$0" build "$2"
|
||||
)
|
||||
|
||||
echo "dump $crateName ($projectDir)"
|
||||
|
||||
so="$so_path/${so_name}.so"
|
||||
|
||||
if [[ ! -r "$so" ]]; then
|
||||
echo "Error: No dump created, cannot read $so"
|
||||
exit 1
|
||||
fi
|
||||
dump="$so_path/${so_name}_dump"
|
||||
(
|
||||
set -x
|
||||
ls -la "$so" > "${dump}_mangled.txt"
|
||||
readelf -aW "$so" >>"${dump}_mangled.txt"
|
||||
"$sdkDir/dependencies/llvm-native/bin/llvm-objdump" \
|
||||
-print-imm-hex \
|
||||
--source \
|
||||
--disassemble \
|
||||
"$so" \
|
||||
>> "${dump}_mangled.txt"
|
||||
sed s/://g <"${dump}_mangled.txt" | rustfilt >"${dump}.txt"
|
||||
)
|
||||
if [[ -f "$dump.txt" ]]; then
|
||||
echo "Created $dump.txt"
|
||||
else
|
||||
echo "Error: No dump created"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "$projectDir does not contain a program, skipping"
|
||||
fi
|
||||
;;
|
||||
fmt)
|
||||
(
|
||||
cd "$projectDir"
|
||||
echo "formatting $projectDir"
|
||||
cargo fmt ${@:3}
|
||||
)
|
||||
;;
|
||||
help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
test)
|
||||
(
|
||||
cd "$projectDir"
|
||||
echo "test $projectDir"
|
||||
cargo test $features ${@:3}
|
||||
)
|
||||
;;
|
||||
update)
|
||||
./bpf-sdk-install.sh
|
||||
./do.sh clean all
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unknown command"
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
set -e
|
||||
if [[ $1 == "update" ]]; then
|
||||
perform_action "$1"
|
||||
exit
|
||||
else
|
||||
if [[ "$#" -lt 2 ]]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
if [[ ! -d "$sdkDir" ]]; then
|
||||
./do.sh update
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $2 == "all" ]]; then
|
||||
# Perform operation on all projects
|
||||
for project in */program*; do
|
||||
if [[ -f "$project"/Cargo.toml ]]; then
|
||||
perform_action "$1" "${project%/}" ${@:3}
|
||||
else
|
||||
continue
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Perform operation on requested project
|
||||
if [[ -d $2/program ]]; then
|
||||
perform_action "$1" "$2/program" "${@:3}"
|
||||
else
|
||||
perform_action "$1" "$2" "${@:3}"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-memo"
|
||||
version = "1.0.9"
|
||||
|
@ -11,12 +8,10 @@ license = "Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
|
||||
[lib]
|
||||
name = "spl_memo"
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
//! Program entrypoint definitions
|
||||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info,
|
||||
program_error::ProgramError, pubkey::Pubkey,
|
||||
};
|
||||
use std::str::from_utf8;
|
||||
|
||||
|
@ -15,18 +12,15 @@ fn process_instruction<'a>(
|
|||
_accounts: &'a [AccountInfo<'a>],
|
||||
instruction_data: &[u8],
|
||||
) -> ProgramResult {
|
||||
info!("hi");
|
||||
from_utf8(instruction_data).map_err(|_| ProgramError::InvalidInstructionData)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Pull in syscall stubs when building for non-BPF targets
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{program_error::ProgramError, pubkey::Pubkey};
|
||||
use solana_program::{program_error::ProgramError, pubkey::Pubkey};
|
||||
|
||||
#[test]
|
||||
fn test_utf8_memo() {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
//! A simple program that accepts a string of encoded characters and verifies that it parses. Currently handles UTF-8.
|
||||
|
||||
pub mod entrypoint;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
mod entrypoint;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_sdk::declare_id!("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo");
|
||||
solana_program::declare_id!("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo");
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Patches the SPL crates for developing against a local solana monorepo
|
||||
#
|
||||
|
||||
solana_dir=$1
|
||||
if [[ -z $solana_dir ]]; then
|
||||
echo "Usage: $0 <path-to-solana-monorepo>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
workspace_crates=(
|
||||
Cargo.toml
|
||||
shared-memory/client/Cargo.toml
|
||||
themis/client_bn/Cargo.toml
|
||||
themis/client_ristretto/Cargo.toml
|
||||
token/perf-monitor/Cargo.toml
|
||||
)
|
||||
|
||||
if [[ ! -r "$solana_dir"/scripts/read-cargo-variable.sh ]]; then
|
||||
echo "$solana_dir is not a path to the solana monorepo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
solana_dir=$(cd "$solana_dir" && pwd)
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
source "$solana_dir"/scripts/read-cargo-variable.sh
|
||||
solana_ver=$(readCargoVariable version "$solana_dir"/sdk/Cargo.toml)
|
||||
|
||||
echo "Patching in $solana_ver from $solana_dir"
|
||||
echo
|
||||
for crate in "${workspace_crates[@]}"; do
|
||||
if grep -q '\[patch.crates-io\]' "$crate"; then
|
||||
echo "$crate is already patched"
|
||||
else
|
||||
cat >> "$crate" <<PATCH
|
||||
[patch.crates-io]
|
||||
solana-account-decoder = {path = "$solana_dir/account-decoder" }
|
||||
solana-banks-client = { path = "$solana_dir/banks-client"}
|
||||
solana-banks-server = { path = "$solana_dir/banks-server"}
|
||||
solana-bpf-loader-program = { path = "$solana_dir/programs/bpf_loader" }
|
||||
solana-clap-utils = {path = "$solana_dir/clap-utils" }
|
||||
solana-cli-config = {path = "$solana_dir/cli-config" }
|
||||
solana-cli-output = {path = "$solana_dir/cli-output" }
|
||||
solana-client = { path = "$solana_dir/client"}
|
||||
solana-core = { path = "$solana_dir/core"}
|
||||
solana-logger = {path = "$solana_dir/logger" }
|
||||
solana-program = { path = "$solana_dir/sdk/program" }
|
||||
solana-runtime = { path = "$solana_dir/runtime" }
|
||||
solana-sdk = { path = "$solana_dir/sdk" }
|
||||
PATCH
|
||||
fi
|
||||
done
|
||||
|
||||
./update-solana-dependencies.sh "$solana_ver"
|
||||
|
|
@ -1713,9 +1713,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-bpf-loader-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4e65edb39170c8cba00256a2ae041c28bbc97cf4add0173543ab0a9893fc91b"
|
||||
checksum = "ffe0627cc4ef87bb00a8691fe7c6bb7eec9efde660c5b02257daf20ccef8286a"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"byteorder",
|
||||
|
@ -1730,9 +1730,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-config-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49d31450d593803698c8df43ba5cd861decfab9ea057899f8e19f50df105c306"
|
||||
checksum = "be3dddd5b85283625f92e1bfa4b100e13c3941ecb472584b29afb5c5382ac09c"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -1744,9 +1744,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-crate-features"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d665c51b3065feb33f641dd1b29d476e11e14dac657725a8ba9af52e68b6618d"
|
||||
checksum = "beeada39ad2aecfee8795d90ca7150389e7f958236f2630825273b9b900a7f19"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes 0.4.12",
|
||||
|
@ -1767,10 +1767,43 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.4.1"
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa91a8812e60bcfdaffaf0d7202a6fb55b64e19a144c313d208829634c69544c"
|
||||
checksum = "63bbbf3bf442bc7e4e76b57af858030fdcb8953cdbcbc6bf3ddd4819aa38e982"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"bv",
|
||||
"generic-array 0.14.4",
|
||||
"log",
|
||||
"memmap",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb4a177d5f46025b619c83d0562e6ea302a871f98148bd7edbc82416ac76949"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8f251c26d46a55bf5c3f6ef5e999e8949909eab952e19a9261e6434ebd31041"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -1779,9 +1812,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-measure"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d31aaf307e4bcc52b18d1fe8971bdede0a0ee0e0242ea322ae5bc2e71bb5883"
|
||||
checksum = "5bacc5ec88bb53610986d49199526fd42dcad7c8b3fc795f3de5740ebff982f4"
|
||||
dependencies = [
|
||||
"jemalloc-ctl",
|
||||
"jemallocator",
|
||||
|
@ -1792,9 +1825,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-metrics"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fd1e167af8decba13acdc487cfb26ffa976e1b2fb7507baa800e9b0ae086729"
|
||||
checksum = "c11d2f59d87ff29d369394654dcff3c66a898b32a351bb67a9ae9de0db2b82f2"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"gethostname",
|
||||
|
@ -1805,10 +1838,40 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.4.1"
|
||||
name = "solana-program"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfb5a22cee0ded53e11090c6bcd963eff6d43caf49c4cda42691e94fab7ddd7d"
|
||||
checksum = "9d4621f2d8ca6d7ac09c0138a02d21def0a736b70feab1f2516f5a74f1ee642f"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bs58",
|
||||
"bv",
|
||||
"curve25519-dalek 2.1.0",
|
||||
"hex",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rustc_version",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-sdk-macro",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84bac623c15acb44f571ec177b67a6434c6aa7637bdb26fe5d776aeb7f4d61ae"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
|
@ -1816,9 +1879,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-runtime"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d511d1dfcf89db6783e83f9f028f139bbff357e190bd0947bd23ff1235f97558"
|
||||
checksum = "8242a732a6db6227854f9bb0c2958c1f219be85989d7ca66d934033d32043c4f"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"blake3",
|
||||
|
@ -1846,12 +1909,13 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-measure",
|
||||
"solana-metrics",
|
||||
"solana-rayon-threadlimit",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-secp256k1-program",
|
||||
"solana-stake-program",
|
||||
"solana-vote-program",
|
||||
|
@ -1864,9 +1928,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e8742ccdaac9ff6e7085e8eb3737858254e4691c6fcaac6b472875db2bbba0d"
|
||||
checksum = "096751fdd2ec2dc3ed7146b1b14245a5b562a21b5046bf3677810a96037aff96"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"bincode",
|
||||
|
@ -1874,7 +1938,6 @@ dependencies = [
|
|||
"bv",
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"curve25519-dalek 2.1.0",
|
||||
"digest 0.9.0",
|
||||
"ed25519-dalek",
|
||||
"generic-array 0.14.4",
|
||||
|
@ -1898,17 +1961,19 @@ dependencies = [
|
|||
"sha2",
|
||||
"sha3",
|
||||
"solana-crate-features",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-program",
|
||||
"solana-sdk-macro",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f38f6c5f3b4119ffa7f75156836e5c88082e557fa978fe1f87995bd386b0d08"
|
||||
checksum = "a02d89c5d8c3c098552e39ad716f8e25b1b9ce95905ad0c770c78d36e1ebcc39"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2 1.0.19",
|
||||
|
@ -1917,24 +1982,11 @@ dependencies = [
|
|||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro-frozen-abi"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e47f618ad2d7af7b9c701e9cc9951681f6d6a9c754863f2ab63e1b98507e515"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-secp256k1-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d8888a924c9183f430a72e1a643648aeff105278bc39315d211bd6b6197e0a0"
|
||||
checksum = "0fa9c6d939374dc10aadb4f5d918134d3388411f8bb975386cd6769afe127268"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"digest 0.9.0",
|
||||
|
@ -1947,9 +1999,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-stake-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3780a14335d07b301128ad518876c8f4c3cb513f88e808faef3ed8a5090abc6"
|
||||
checksum = "1decea030cb64647c3bee685d804344c10de071ec03f0331436c8c90b500ca27"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -1959,18 +2011,19 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-metrics",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-vote-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-vote-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "595274785736cbae1f012ed1c78aebbbe2cf75720dec1e1850800c9cd64fae9b"
|
||||
checksum = "b44aeb9a4169443ce3d2ee417fe61abc1067d6d842e609f3ec30e462b98fae45"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -1979,10 +2032,11 @@ dependencies = [
|
|||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-metrics",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -2015,7 +2069,7 @@ name = "spl-shared-memory"
|
|||
version = "2.0.6"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"solana-sdk",
|
||||
"solana-program",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -10,8 +10,7 @@ edition = "2018"
|
|||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
spl-shared-memory = { path = "../program" }
|
||||
solana-bpf-loader-program = { version = "1.3.17" }
|
||||
solana-bpf-loader-program = "1.4.3"
|
||||
solana_rbpf = "=0.1.32"
|
||||
solana-runtime = { version = "1.3.17" }
|
||||
solana-sdk = { version = "1.3.17" }
|
||||
|
||||
solana-runtime = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use std::{fs::canonicalize, process::Command};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:warning=(not a warning) Building SPL Shared-memory shared object");
|
||||
Command::new(canonicalize("../../do.sh").unwrap())
|
||||
.current_dir("../..")
|
||||
.arg("build")
|
||||
.arg("shared-memory/program")
|
||||
println!("cargo:warning=(not a warning) Building BPF shared-memory program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build shared-memory program")
|
||||
.expect("Failed to build BPF shared-memory program")
|
||||
.success();
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ fn run_program(
|
|||
fn assert_instruction_count() {
|
||||
const OFFSET: usize = 51;
|
||||
const NUM_TO_SHARE: usize = 500;
|
||||
let program_id = Pubkey::new_rand();
|
||||
let shared_key = Pubkey::new_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let shared_key = Pubkey::new_unique();
|
||||
let shared_account = Account::new_ref(u64::MAX, OFFSET + NUM_TO_SHARE * 2, &program_id);
|
||||
|
||||
// Send some data to share
|
||||
|
@ -99,7 +99,7 @@ fn test_share_data() {
|
|||
const OFFSET: usize = 51;
|
||||
const NUM_TO_SHARE: usize = 500;
|
||||
let program_id = Pubkey::new(&[0; 32]);
|
||||
let shared_key = Pubkey::new_rand();
|
||||
let shared_key = Pubkey::new_unique();
|
||||
let shared_account = Account::new_ref(u64::MAX, NUM_TO_SHARE * 2, &program_id);
|
||||
|
||||
// success
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-shared-memory"
|
||||
version = "2.0.6"
|
||||
|
@ -11,13 +8,9 @@ license = "Apache-2.0"
|
|||
edition = "2018"
|
||||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
|
||||
[dependencies]
|
||||
arrayref = "0.3.6"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![deny(missing_docs)]
|
||||
|
||||
//! Shared memory program for the Solana blockchain.
|
||||
//
|
||||
// Useful for returning data from cross-program invoked programs to the invoker.
|
||||
|
@ -7,11 +6,11 @@
|
|||
// This program is highly optimized for its particular use case and does not
|
||||
// implement the typical `process_instruction` entrypoint.
|
||||
|
||||
extern crate solana_sdk;
|
||||
extern crate solana_program;
|
||||
use arrayref::{array_refs, mut_array_refs};
|
||||
use solana_sdk::{
|
||||
entrypoint::MAX_PERMITTED_DATA_INCREASE, entrypoint::SUCCESS, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
use solana_program::{
|
||||
declare_id, entrypoint::MAX_PERMITTED_DATA_INCREASE, entrypoint::SUCCESS,
|
||||
program_error::ProgramError, pubkey::Pubkey,
|
||||
};
|
||||
use std::{
|
||||
mem::{align_of, size_of},
|
||||
|
@ -19,7 +18,7 @@ use std::{
|
|||
slice::{from_raw_parts, from_raw_parts_mut},
|
||||
};
|
||||
|
||||
solana_sdk::declare_id!("shmem4EWT2sPdVGvTZCzXXRAURL9G5vpPxNwSeKhHUL");
|
||||
declare_id!("shmem4EWT2sPdVGvTZCzXXRAURL9G5vpPxNwSeKhHUL");
|
||||
|
||||
/// A more efficient `copy_from_slice` implementation.
|
||||
fn fast_copy(mut src: &[u8], mut dst: &mut [u8]) {
|
||||
|
|
|
@ -11,13 +11,13 @@ version = "2.0.1"
|
|||
[dependencies]
|
||||
clap = "2.33.3"
|
||||
serde_json = "1.0.57"
|
||||
solana-account-decoder = { version = "1.3.9" }
|
||||
solana-clap-utils = { version = "1.3.9"}
|
||||
solana-cli-config = { version = "1.3.9" }
|
||||
solana-client = { version = "1.3.9" }
|
||||
solana-logger = { version = "1.3.9" }
|
||||
solana-sdk = { version = "1.3.9" }
|
||||
spl-stake-pool = { version = "2.0", path="../program" }
|
||||
solana-account-decoder = "1.4.3"
|
||||
solana-clap-utils = "1.4.3"
|
||||
solana-cli-config = "1.4.3"
|
||||
solana-client = "1.4.3"
|
||||
solana-logger = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
spl-stake-pool = { version = "0.1.0", path="../program", features = [ "exclude_entrypoint" ] }
|
||||
|
||||
[[bin]]
|
||||
name = "spl-stake-pool"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-stake-pool"
|
||||
version = "0.1.0"
|
||||
|
@ -12,17 +9,14 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program", "spl-token/program", "spl-token/no-entrypoint"]
|
||||
default = ["solana-sdk/default", "spl-token/default"]
|
||||
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
remove_dir_all = "=0.5.0"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
spl-token = { path = "../../token/program", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
spl-token = { path = "../../token/program", features = [ "exclude_entrypoint" ] }
|
||||
thiserror = "1.0"
|
||||
arrayref = "0.3.6"
|
||||
num_enum = "0.5.1"
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use crate::{error::Error, processor::Processor};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Error types
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the StakePool program.
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use solana_sdk::instruction::AccountMeta;
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_sdk::program_error::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_program::instruction::AccountMeta;
|
||||
use solana_program::instruction::Instruction;
|
||||
use solana_program::program_error::ProgramError;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
use std::mem::size_of;
|
||||
|
||||
/// Fee rate as a ratio
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
//! A program for creating pools of Solana stakes managed by a Stake-o-Matic
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod processor;
|
||||
pub mod stake;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
pub mod entrypoint;
|
||||
|
||||
solana_sdk::declare_id!("STAKEPQQL1111111111111111111111111111111111");
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_program::declare_id!("STAKEPQQL1111111111111111111111111111111111");
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
//! Program state processor
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
|
||||
use crate::{
|
||||
error::Error,
|
||||
instruction::{InitArgs, StakePoolInstruction},
|
||||
|
@ -10,10 +8,10 @@ use crate::{
|
|||
};
|
||||
use num_traits::FromPrimitive;
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_program::instruction::Instruction;
|
||||
#[cfg(target_arch = "bpf")]
|
||||
use solana_sdk::program::invoke_signed;
|
||||
use solana_sdk::{
|
||||
use solana_program::program::invoke_signed;
|
||||
use solana_program::{
|
||||
account_info::next_account_info, account_info::AccountInfo, decode_error::DecodeError,
|
||||
entrypoint::ProgramResult, info, program_error::PrintProgramError, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
@ -607,10 +605,6 @@ impl PrintProgramError for Error {
|
|||
}
|
||||
}
|
||||
|
||||
// Pull in syscall stubs when building for non-BPF targets
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -618,7 +612,7 @@ mod tests {
|
|||
use crate::instruction::Fee;
|
||||
use crate::instruction::InitArgs;
|
||||
use core::mem::size_of;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account::Account, account_info::create_is_signer_account_infos, instruction::Instruction,
|
||||
program_pack::Pack, rent::Rent, sysvar::rent,
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
//! FIXME copied from the solana stake program
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
sysvar,
|
||||
};
|
||||
|
||||
solana_sdk::declare_id!("StakeConfig11111111111111111111111111111111");
|
||||
solana_program::declare_id!("StakeConfig11111111111111111111111111111111");
|
||||
|
||||
/// FIXME copied from solana stake program
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::error::Error;
|
||||
use crate::instruction::{unpack, Fee};
|
||||
use solana_sdk::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};
|
||||
use solana_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};
|
||||
use std::mem::size_of;
|
||||
|
||||
/// Initialized program details.
|
||||
|
|
|
@ -9,31 +9,26 @@ license = "Apache-2.0"
|
|||
edition = "2018"
|
||||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.3"
|
||||
borsh = "0.7.1"
|
||||
bn = {git = "https://github.com/garious/bn", rev = "5c35c737ffabac9921310f53f48725216d59cbf1", default-features = false, features = ["borsh"]}
|
||||
elgamal_bn = { git = "https://github.com/garious/elgamal_bn", rev = "ba9bdcdb6cdd6fb8e74d0b8bc1b918bcd1b543a9" }
|
||||
futures = "0.3"
|
||||
solana-banks-client = "1.4.1"
|
||||
solana-cli-config = "1.4.1"
|
||||
solana-sdk = "1.4.1"
|
||||
spl-themis-bn = { version = "0.1.0", path = "../program_bn" }
|
||||
solana-banks-client = "1.4.3"
|
||||
solana-cli-config = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
spl-themis-bn = { version = "0.1.0", path = "../program_bn", features = ["exclude_entrypoint"]}
|
||||
tarpc = { version = "0.21.1", features = ["full"] }
|
||||
tokio = "0.2"
|
||||
url = "2.1"
|
||||
|
||||
[dev-dependencies]
|
||||
separator = "0.4.1"
|
||||
solana-banks-server = "1.4.1"
|
||||
solana-bpf-loader-program = "1.4.1"
|
||||
solana-banks-server = "1.4.3"
|
||||
solana-bpf-loader-program = "1.4.3"
|
||||
solana_rbpf = "=0.1.32"
|
||||
solana-runtime = "1.4.1"
|
||||
solana-runtime = "1.4.3"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use std::{fs::canonicalize, process::Command};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:warning=(not a warning) Building SPL Themis shared object");
|
||||
Command::new(canonicalize("../../do.sh").unwrap())
|
||||
.current_dir("../..")
|
||||
.arg("build")
|
||||
.arg("themis/program_bn")
|
||||
println!("cargo:warning=(not a warning) Building BPF themis program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build themis program")
|
||||
.expect("Failed to build BPF themis program")
|
||||
.success();
|
||||
}
|
||||
|
|
|
@ -75,10 +75,10 @@ fn run_program(
|
|||
|
||||
#[test]
|
||||
fn assert_instruction_count() {
|
||||
let program_id = Pubkey::new_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
|
||||
// Create new policies
|
||||
let policies_key = Pubkey::new_rand();
|
||||
let policies_key = Pubkey::new_unique();
|
||||
let scalars = vec![Fr::new(1u64.into()).unwrap(), Fr::new(2u64.into()).unwrap()];
|
||||
//let scalars = vec![
|
||||
// Fr::new(1u64.into()).unwrap(),
|
||||
|
@ -211,7 +211,7 @@ fn assert_instruction_count() {
|
|||
run_program(&program_id, ¶meter_accounts[..], &instruction_data).unwrap();
|
||||
|
||||
// Create user account
|
||||
let user_key = Pubkey::new_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let user_account =
|
||||
SolanaAccount::new_ref(0, User::default().try_to_vec().unwrap().len(), &program_id);
|
||||
let instruction_data = ThemisInstruction::InitializeUserAccount { public_key: pk }
|
||||
|
|
|
@ -9,32 +9,27 @@ license = "Apache-2.0"
|
|||
edition = "2018"
|
||||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.3"
|
||||
borsh = "0.7.1"
|
||||
curve25519-dalek = {git = "https://github.com/garious/curve25519-dalek", rev = "60efef3553d6bf3d7f3b09b5f97acd54d72529ff", default-features = false, features = ["borsh"]}
|
||||
elgamal_ristretto = { git = "https://github.com/garious/elgamal", rev = "db1eef8e01b8a6e93d3bdc64ab2c1acb39cb64d6", default-features = false }
|
||||
futures = "0.3"
|
||||
solana-banks-client = "1.4.1"
|
||||
solana-cli-config = "1.4.1"
|
||||
solana-sdk = "1.4.1"
|
||||
spl-themis-ristretto = { version = "0.1.0", path = "../program_ristretto" }
|
||||
solana-banks-client = "1.4.3"
|
||||
solana-cli-config = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
spl-themis-ristretto = { version = "0.1.0", path = "../program_ristretto", features = ["exclude_entrypoint"] }
|
||||
tarpc = { version = "0.22.0", features = ["full"] }
|
||||
tokio = "0.2"
|
||||
url = "2.1"
|
||||
|
||||
[dev-dependencies]
|
||||
separator = "0.4.1"
|
||||
solana-banks-server = "1.4.1"
|
||||
solana-bpf-loader-program = "1.4.1"
|
||||
solana-core = "1.4.1"
|
||||
solana-banks-server = "1.4.3"
|
||||
solana-bpf-loader-program = "1.4.3"
|
||||
solana-core = "1.4.3"
|
||||
solana_rbpf = "=0.1.32"
|
||||
solana-runtime = "1.4.1"
|
||||
solana-runtime = "1.4.3"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use std::{fs::canonicalize, process::Command};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:warning=(not a warning) Building SPL Themis shared object");
|
||||
Command::new(canonicalize("../../do.sh").unwrap())
|
||||
.current_dir("../..")
|
||||
.arg("build")
|
||||
.arg("themis/program_ristretto")
|
||||
println!("cargo:warning=(not a warning) Building BPF themis program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build themis program")
|
||||
.expect("Failed to build BPF themis program")
|
||||
.success();
|
||||
}
|
||||
|
|
|
@ -75,10 +75,10 @@ fn run_program(
|
|||
|
||||
#[test]
|
||||
fn assert_instruction_count() {
|
||||
let program_id = Pubkey::new_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
|
||||
// Create new policies
|
||||
let policies_key = Pubkey::new_rand();
|
||||
let policies_key = Pubkey::new_unique();
|
||||
let scalars = vec![1u64.into(), 2u64.into()];
|
||||
//let scalars = vec![
|
||||
// 1u64.into(),
|
||||
|
@ -211,7 +211,7 @@ fn assert_instruction_count() {
|
|||
run_program(&program_id, ¶meter_accounts[..], &instruction_data).unwrap();
|
||||
|
||||
// Create user account
|
||||
let user_key = Pubkey::new_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let user_account =
|
||||
SolanaAccount::new_ref(0, User::default().try_to_vec().unwrap().len(), &program_id);
|
||||
let instruction_data = ThemisInstruction::InitializeUserAccount { public_key: pk }
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-themis-bn"
|
||||
version = "0.1.0"
|
||||
|
@ -12,9 +9,7 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.3"
|
||||
|
@ -25,9 +20,8 @@ getrandom = { version = "0.1.15", features = ["dummy"] }
|
|||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
rand = "0.7.0"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
thiserror = "1.0"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
use solana_sdk::program_error::PrintProgramError;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::program_error::PrintProgramError;
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the Themis program.
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::state::{Policies, User};
|
|||
use bn::{Fr, G1};
|
||||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use elgamal_bn::public::PublicKey;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
//! An implementation of Brave's THEMIS for the Solana blockchain
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
pub mod entrypoint;
|
||||
|
||||
solana_sdk::declare_id!("F3FWeYPjD1jeR6UykMj1GRbCcmoxtJnDiPuFdTLRGvb6");
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_program::declare_id!("F3FWeYPjD1jeR6UykMj1GRbCcmoxtJnDiPuFdTLRGvb6");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//! Themis program
|
||||
|
||||
use crate::{
|
||||
error::ThemisError,
|
||||
instruction::ThemisInstruction,
|
||||
|
@ -6,7 +7,7 @@ use crate::{
|
|||
};
|
||||
use bn::{Fr, G1};
|
||||
use elgamal_bn::public::PublicKey;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
|
|
@ -4,7 +4,7 @@ use bn::{Fr, Group, G1};
|
|||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use elgamal_bn::{ciphertext::Ciphertext, private::SecretKey, public::PublicKey};
|
||||
use rand::thread_rng;
|
||||
use solana_sdk::program_error::ProgramError;
|
||||
use solana_program::program_error::ProgramError;
|
||||
|
||||
type Points = (G1, G1);
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-themis-ristretto"
|
||||
version = "0.1.0"
|
||||
|
@ -12,9 +9,8 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program", "elgamal_ristretto/program"]
|
||||
default = ["solana-sdk/default", "elgamal_ristretto/default"]
|
||||
exclude_entrypoint = []
|
||||
default = ["elgamal_ristretto/program"]
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.3"
|
||||
|
@ -25,9 +21,8 @@ getrandom = { version = "0.1.15", features = ["dummy"] }
|
|||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
rand = "0.7.0"
|
||||
solana-sdk = { version = "1.4.1", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
thiserror = "1.0"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
use solana_sdk::program_error::PrintProgramError;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::program_error::PrintProgramError;
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the Themis program.
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::state::{Policies, User};
|
|||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
|
||||
use elgamal_ristretto::public::PublicKey;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
//! An implementation of Brave's THEMIS for the Solana blockchain
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
pub mod entrypoint;
|
||||
|
||||
solana_sdk::declare_id!("C8tR6A3CWcEL46KHx7TJcbyR4hdoPi1wrBBQa42FuJMF");
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_program::declare_id!("C8tR6A3CWcEL46KHx7TJcbyR4hdoPi1wrBBQa42FuJMF");
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
};
|
||||
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
|
||||
use elgamal_ristretto::public::PublicKey;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
|
|
@ -9,7 +9,7 @@ use elgamal_ristretto::{
|
|||
ciphertext::Ciphertext, multiply::ristretto_mul, private::SecretKey, public::PublicKey,
|
||||
};
|
||||
use rand::thread_rng;
|
||||
use solana_sdk::program_error::ProgramError;
|
||||
use solana_program::program_error::ProgramError;
|
||||
|
||||
type Points = (RistrettoPoint, RistrettoPoint);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"testnetDefaultChannel": "edge",
|
||||
"scripts": {
|
||||
"build": "rollup -c rollup.config.ts",
|
||||
"build:program": "rm client/util/store/config.json; ../../do.sh build token-lending",
|
||||
"build:program": "rm -f client/util/store/config.json; cargo build-bpf --manifest-path ../program/Cargo.toml",
|
||||
"start": "ts-node cli/main.ts",
|
||||
"lint": "eslint --ext .ts {cli,client}/* && prettier --check \"{cli,client}/**/*.ts\"",
|
||||
"lint:fix": "eslint --ext .ts {cli,client}/* --fix && prettier --write \"{cli,client}/**/*.ts\"",
|
||||
|
@ -33,7 +33,7 @@
|
|||
"cluster:testnet": "cp cluster-testnet.env .env",
|
||||
"cluster:mainnet-beta": "cp cluster-mainnet-beta.env .env",
|
||||
"localnet:update": "solana-localnet update",
|
||||
"localnet:up": "rm client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:up": "rm -f client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:down": "solana-localnet down",
|
||||
"localnet:logs": "solana-localnet logs -f"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-token-lending"
|
||||
version = "0.1.0"
|
||||
|
@ -11,20 +8,17 @@ license = "Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
arrayref = "0.3.6"
|
||||
num_enum = "0.5.1"
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
solana-sdk = { version = "1.3.17", default-features = false }
|
||||
solana-program = "1.4.3"
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
//! Program entrypoint definitions
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use crate::{error::LendingError, processor::Processor};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Error types
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the TokenLending program.
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
//! A lending program for the Solana blockchain.
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
pub mod entrypoint;
|
||||
|
||||
solana_sdk::declare_id!("TokenLend1ng1111111111111111111111111111111");
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_program::declare_id!("TokenLend1ng1111111111111111111111111111111");
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
//! Program state processor
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
|
||||
use crate::error::LendingError;
|
||||
use num_traits::FromPrimitive;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, decode_error::DecodeError, entrypoint::ProgramResult, info,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
"flow": "flow",
|
||||
"flow:watch": "watch 'flow' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
||||
"lint:watch": "watch 'npm run lint:fix' . --wait=1",
|
||||
"build:program": "rm client/util/store/config.json; ../../do.sh build token-swap",
|
||||
"build:program": "rm -f client/util/store/config.json; cargo build-bpf --manifest-path ../program/Cargo.toml",
|
||||
"cluster:localnet": "rm -f .env",
|
||||
"cluster:devnet": "cp cluster-devnet.env .env",
|
||||
"cluster:testnet": "cp cluster-testnet.env .env",
|
||||
"cluster:mainnet-beta": "cp cluster-mainnet-beta.env .env",
|
||||
"localnet:update": "solana-localnet update",
|
||||
"localnet:up": "rm client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:up": "rm -f client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:down": "solana-localnet down",
|
||||
"localnet:logs": "solana-localnet logs -f",
|
||||
"pretty": "prettier --check '{,cli*/**/}*.[jt]s'",
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-token-swap"
|
||||
version = "0.1.0"
|
||||
|
@ -12,21 +9,18 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program", "spl-token/program", "spl-token/no-entrypoint"]
|
||||
default = ["solana-sdk/default", "spl-token/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
arrayref = "0.3.6"
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
remove_dir_all = "=0.5.0"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
spl-token = { path = "../../token/program", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
spl-token = { path = "../../token/program", features = [ "exclude_entrypoint" ] }
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
|
||||
[lib]
|
||||
name = "spl_token_swap"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
//! Swap calculations and curve implementations
|
||||
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
program_error::ProgramError,
|
||||
program_pack::{IsInitialized, Pack, Sealed},
|
||||
};
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
//! Program entrypoint definitions
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use crate::{error::SwapError, processor::Processor};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Error types
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the TokenSwap program.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::curve::SwapCurve;
|
||||
use crate::error::SwapError;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
program_pack::Pack,
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
//! An Uniswap-like program for the Solana blockchain.
|
||||
|
||||
pub mod curve;
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
mod entrypoint;
|
||||
|
||||
solana_sdk::declare_id!("TokenSwap1111111111111111111111111111111111");
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
solana_program::declare_id!("TokenSwap1111111111111111111111111111111111");
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
//! Program state processor
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
//#![cfg(feature = "program")]
|
||||
|
||||
use crate::{curve::SwapCurve, error::SwapError, instruction::SwapInstruction, state::SwapInfo};
|
||||
use num_traits::FromPrimitive;
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_program::instruction::Instruction;
|
||||
#[cfg(target_arch = "bpf")]
|
||||
use solana_sdk::program::invoke_signed;
|
||||
use solana_sdk::{
|
||||
use solana_program::program::invoke_signed;
|
||||
use solana_program::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
decode_error::DecodeError,
|
||||
entrypoint::ProgramResult,
|
||||
|
@ -672,10 +672,6 @@ impl PrintProgramError for SwapError {
|
|||
}
|
||||
}
|
||||
|
||||
// Pull in syscall stubs when building for non-BPF targets
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -685,7 +681,7 @@ mod tests {
|
|||
},
|
||||
instruction::{deposit, initialize, swap, withdraw},
|
||||
};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account::Account, account_info::create_is_signer_account_infos, instruction::Instruction,
|
||||
rent::Rent, sysvar::rent,
|
||||
};
|
||||
|
@ -728,7 +724,7 @@ mod tests {
|
|||
token_a_amount: u64,
|
||||
token_b_amount: u64,
|
||||
) -> Self {
|
||||
let swap_key = pubkey_rand();
|
||||
let swap_key = Pubkey::new_unique();
|
||||
let swap_account = Account::new(0, SwapInfo::get_packed_len(), &SWAP_PROGRAM_ID);
|
||||
let (authority_key, nonce) =
|
||||
Pubkey::find_program_address(&[&swap_key.to_bytes()[..]], &SWAP_PROGRAM_ID);
|
||||
|
@ -886,6 +882,7 @@ mod tests {
|
|||
panic!("Could not find matching swap token account");
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn swap(
|
||||
&mut self,
|
||||
user_key: &Pubkey,
|
||||
|
@ -956,6 +953,7 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn deposit(
|
||||
&mut self,
|
||||
depositor_key: &Pubkey,
|
||||
|
@ -1036,6 +1034,7 @@ mod tests {
|
|||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn withdraw(
|
||||
&mut self,
|
||||
user_key: &Pubkey,
|
||||
|
@ -1111,10 +1110,6 @@ mod tests {
|
|||
Rent::default().minimum_balance(SplAccount::get_packed_len())
|
||||
}
|
||||
|
||||
fn pubkey_rand() -> Pubkey {
|
||||
Pubkey::new(&rand::random::<[u8; 32]>())
|
||||
}
|
||||
|
||||
fn do_process_instruction(
|
||||
instruction: Instruction,
|
||||
accounts: Vec<&mut Account>,
|
||||
|
@ -1164,7 +1159,7 @@ mod tests {
|
|||
account_owner_key: &Pubkey,
|
||||
amount: u64,
|
||||
) -> (Pubkey, Account) {
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = Account::new(
|
||||
account_minimum_balance(),
|
||||
SplAccount::get_packed_len(),
|
||||
|
@ -1212,7 +1207,7 @@ mod tests {
|
|||
authority_key: &Pubkey,
|
||||
freeze_authority: Option<&Pubkey>,
|
||||
) -> (Pubkey, Account) {
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account = Account::new(
|
||||
mint_minimum_balance(),
|
||||
SplMint::get_packed_len(),
|
||||
|
@ -1231,9 +1226,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_token_program_id_error() {
|
||||
let swap_key = pubkey_rand();
|
||||
let mut mint = (pubkey_rand(), Account::default());
|
||||
let mut destination = (pubkey_rand(), Account::default());
|
||||
let swap_key = Pubkey::new_unique();
|
||||
let mut mint = (Pubkey::new_unique(), Account::default());
|
||||
let mut destination = (Pubkey::new_unique(), Account::default());
|
||||
let token_program = (TOKEN_PROGRAM_ID, Account::default());
|
||||
let (authority_key, nonce) =
|
||||
Pubkey::find_program_address(&[&swap_key.to_bytes()[..]], &SWAP_PROGRAM_ID);
|
||||
|
@ -1260,7 +1255,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_initialize() {
|
||||
let user_key = pubkey_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let trade_fee_numerator = 1;
|
||||
let trade_fee_denominator = 2;
|
||||
let owner_trade_fee_numerator = 1;
|
||||
|
@ -1680,7 +1675,7 @@ mod tests {
|
|||
|
||||
// wrong token program id
|
||||
{
|
||||
let wrong_program_id = pubkey_rand();
|
||||
let wrong_program_id = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(ProgramError::InvalidAccountData),
|
||||
do_process_instruction(
|
||||
|
@ -1784,8 +1779,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_deposit() {
|
||||
let user_key = pubkey_rand();
|
||||
let depositor_key = pubkey_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let depositor_key = Pubkey::new_unique();
|
||||
let trade_fee_numerator = 1;
|
||||
let trade_fee_denominator = 2;
|
||||
let owner_trade_fee_numerator = 1;
|
||||
|
@ -2059,7 +2054,7 @@ mod tests {
|
|||
pool_key,
|
||||
mut pool_account,
|
||||
) = accounts.setup_token_accounts(&user_key, &depositor_key, deposit_a, deposit_b, 0);
|
||||
let wrong_key = pubkey_rand();
|
||||
let wrong_key = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(ProgramError::InvalidAccountData),
|
||||
do_process_instruction(
|
||||
|
@ -2108,7 +2103,7 @@ mod tests {
|
|||
let old_a_key = accounts.token_a_key;
|
||||
let old_a_account = accounts.token_a_account;
|
||||
|
||||
accounts.token_a_key = token_a_key.clone();
|
||||
accounts.token_a_key = token_a_key;
|
||||
accounts.token_a_account = token_a_account.clone();
|
||||
|
||||
// wrong swap token a account
|
||||
|
@ -2134,7 +2129,7 @@ mod tests {
|
|||
let old_b_key = accounts.token_b_key;
|
||||
let old_b_account = accounts.token_b_account;
|
||||
|
||||
accounts.token_b_key = token_b_key.clone();
|
||||
accounts.token_b_key = token_b_key;
|
||||
accounts.token_b_account = token_b_account.clone();
|
||||
|
||||
// wrong swap token b account
|
||||
|
@ -2314,7 +2309,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_withdraw() {
|
||||
let user_key = pubkey_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let trade_fee_numerator = 1;
|
||||
let trade_fee_denominator = 2;
|
||||
let owner_trade_fee_numerator = 1;
|
||||
|
@ -2336,7 +2331,7 @@ mod tests {
|
|||
}),
|
||||
};
|
||||
|
||||
let withdrawer_key = pubkey_rand();
|
||||
let withdrawer_key = Pubkey::new_unique();
|
||||
let initial_a = token_a_amount / 10;
|
||||
let initial_b = token_b_amount / 10;
|
||||
let initial_pool = swap_curve.calculator.new_pool_supply() / 10;
|
||||
|
@ -2638,7 +2633,7 @@ mod tests {
|
|||
initial_b,
|
||||
withdraw_amount,
|
||||
);
|
||||
let wrong_key = pubkey_rand();
|
||||
let wrong_key = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(ProgramError::InvalidAccountData),
|
||||
do_process_instruction(
|
||||
|
@ -2695,7 +2690,7 @@ mod tests {
|
|||
let old_a_key = accounts.token_a_key;
|
||||
let old_a_account = accounts.token_a_account;
|
||||
|
||||
accounts.token_a_key = token_a_key.clone();
|
||||
accounts.token_a_key = token_a_key;
|
||||
accounts.token_a_account = token_a_account.clone();
|
||||
|
||||
// wrong swap token a account
|
||||
|
@ -2721,7 +2716,7 @@ mod tests {
|
|||
let old_b_key = accounts.token_b_key;
|
||||
let old_b_account = accounts.token_b_account;
|
||||
|
||||
accounts.token_b_key = token_b_key.clone();
|
||||
accounts.token_b_key = token_b_key;
|
||||
accounts.token_b_account = token_b_account.clone();
|
||||
|
||||
// wrong swap token b account
|
||||
|
@ -2955,7 +2950,7 @@ mod tests {
|
|||
mut _pool_account,
|
||||
) = accounts.setup_token_accounts(&user_key, &withdrawer_key, 0, 0, 0);
|
||||
|
||||
let pool_fee_key = accounts.pool_fee_key.clone();
|
||||
let pool_fee_key = accounts.pool_fee_key;
|
||||
let mut pool_fee_account = accounts.pool_fee_account.clone();
|
||||
let fee_account = Processor::unpack_token_account(&pool_fee_account.data).unwrap();
|
||||
let pool_fee_amount = fee_account.amount;
|
||||
|
@ -3006,8 +3001,8 @@ mod tests {
|
|||
}
|
||||
|
||||
fn check_valid_swap_curve(curve_type: CurveType, calculator: Box<dyn CurveCalculator>) {
|
||||
let user_key = pubkey_rand();
|
||||
let swapper_key = pubkey_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let swapper_key = Pubkey::new_unique();
|
||||
let token_a_amount = 1000;
|
||||
let token_b_amount = 5000;
|
||||
|
||||
|
@ -3177,8 +3172,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_swap() {
|
||||
let user_key = pubkey_rand();
|
||||
let swapper_key = pubkey_rand();
|
||||
let user_key = Pubkey::new_unique();
|
||||
let swapper_key = Pubkey::new_unique();
|
||||
let trade_fee_numerator = 1;
|
||||
let trade_fee_denominator = 4;
|
||||
let owner_trade_fee_numerator = 1;
|
||||
|
@ -3206,8 +3201,8 @@ mod tests {
|
|||
let initial_b = token_b_amount / 5;
|
||||
let minimum_b_amount = initial_b / 2;
|
||||
|
||||
let swap_token_a_key = accounts.token_a_key.clone();
|
||||
let swap_token_b_key = accounts.token_b_key.clone();
|
||||
let swap_token_a_key = accounts.token_a_key;
|
||||
let swap_token_b_key = accounts.token_b_key;
|
||||
|
||||
// swap not initialized
|
||||
{
|
||||
|
@ -3280,7 +3275,7 @@ mod tests {
|
|||
_pool_key,
|
||||
_pool_account,
|
||||
) = accounts.setup_token_accounts(&user_key, &swapper_key, initial_a, initial_b, 0);
|
||||
let wrong_program_id = pubkey_rand();
|
||||
let wrong_program_id = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(ProgramError::InvalidAccountData),
|
||||
do_process_instruction(
|
||||
|
@ -3572,7 +3567,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
// slippage exceeeded: minimum out amount too high
|
||||
// slippage exceeded: minimum out amount too high
|
||||
{
|
||||
let (
|
||||
token_a_key,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::curve::SwapCurve;
|
||||
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
program_error::ProgramError,
|
||||
program_pack::{IsInitialized, Pack, Sealed},
|
||||
pubkey::Pubkey,
|
||||
|
|
|
@ -12,14 +12,14 @@ version = "2.0.3"
|
|||
clap = "2.33.3"
|
||||
console = "0.13.0"
|
||||
serde_json = "1.0.59"
|
||||
solana-account-decoder = { version = "=1.4.1" }
|
||||
solana-clap-utils = { version = "=1.4.1"}
|
||||
solana-cli-config = { version = "=1.4.2" }
|
||||
solana-cli-output = { version = "=1.4.1" }
|
||||
solana-client = { version = "=1.4.1" }
|
||||
solana-logger = { version = "=1.4.2" }
|
||||
solana-sdk = { version = "=1.4.1" }
|
||||
spl-token = { version = "2.0", path="../program" }
|
||||
solana-account-decoder = "1.4.3"
|
||||
solana-clap-utils = "1.4.3"
|
||||
solana-cli-config = "1.4.3"
|
||||
solana-cli-output = "1.4.3"
|
||||
solana-client = "1.4.3"
|
||||
solana-logger = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
spl-token = { version = "2.0", path="../program", features = [ "exclude_entrypoint" ] }
|
||||
|
||||
[[bin]]
|
||||
name = "spl-token"
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
"flow": "flow",
|
||||
"flow:watch": "watch 'flow' . --wait=1 --ignoreDirectoryPattern=/doc/",
|
||||
"lint:watch": "watch 'npm run lint:fix' . --wait=1",
|
||||
"build:program": "rm client/util/store/config.json; ../../do.sh build token",
|
||||
"build:program": "rm -f client/util/store/config.json; cargo build-bpf --manifest-path ../program/Cargo.toml",
|
||||
"cluster:localnet": "rm -f .env",
|
||||
"cluster:devnet": "cp cluster-devnet.env .env",
|
||||
"cluster:testnet": "cp cluster-testnet.env .env",
|
||||
"cluster:mainnet-beta": "cp cluster-mainnet-beta.env .env",
|
||||
"localnet:update": "solana-localnet update",
|
||||
"localnet:up": "rm client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:up": "rm -f client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
|
||||
"localnet:down": "solana-localnet down",
|
||||
"localnet:logs": "solana-localnet logs -f",
|
||||
"pretty": "prettier --check '{,cli*/**/}*.[jt]s'",
|
||||
|
|
|
@ -1755,9 +1755,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-bpf-loader-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4e65edb39170c8cba00256a2ae041c28bbc97cf4add0173543ab0a9893fc91b"
|
||||
checksum = "ffe0627cc4ef87bb00a8691fe7c6bb7eec9efde660c5b02257daf20ccef8286a"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"byteorder",
|
||||
|
@ -1772,9 +1772,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-config-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49d31450d593803698c8df43ba5cd861decfab9ea057899f8e19f50df105c306"
|
||||
checksum = "be3dddd5b85283625f92e1bfa4b100e13c3941ecb472584b29afb5c5382ac09c"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -1786,9 +1786,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-crate-features"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d665c51b3065feb33f641dd1b29d476e11e14dac657725a8ba9af52e68b6618d"
|
||||
checksum = "beeada39ad2aecfee8795d90ca7150389e7f958236f2630825273b9b900a7f19"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes 0.4.12",
|
||||
|
@ -1809,10 +1809,43 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.4.1"
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa91a8812e60bcfdaffaf0d7202a6fb55b64e19a144c313d208829634c69544c"
|
||||
checksum = "63bbbf3bf442bc7e4e76b57af858030fdcb8953cdbcbc6bf3ddd4819aa38e982"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"bv",
|
||||
"generic-array 0.14.4",
|
||||
"log",
|
||||
"memmap",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb4a177d5f46025b619c83d0562e6ea302a871f98148bd7edbc82416ac76949"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8f251c26d46a55bf5c3f6ef5e999e8949909eab952e19a9261e6434ebd31041"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -1821,9 +1854,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-measure"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d31aaf307e4bcc52b18d1fe8971bdede0a0ee0e0242ea322ae5bc2e71bb5883"
|
||||
checksum = "5bacc5ec88bb53610986d49199526fd42dcad7c8b3fc795f3de5740ebff982f4"
|
||||
dependencies = [
|
||||
"jemalloc-ctl",
|
||||
"jemallocator",
|
||||
|
@ -1834,9 +1867,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-metrics"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fd1e167af8decba13acdc487cfb26ffa976e1b2fb7507baa800e9b0ae086729"
|
||||
checksum = "c11d2f59d87ff29d369394654dcff3c66a898b32a351bb67a9ae9de0db2b82f2"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"gethostname",
|
||||
|
@ -1847,10 +1880,40 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.4.1"
|
||||
name = "solana-program"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfb5a22cee0ded53e11090c6bcd963eff6d43caf49c4cda42691e94fab7ddd7d"
|
||||
checksum = "9d4621f2d8ca6d7ac09c0138a02d21def0a736b70feab1f2516f5a74f1ee642f"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bs58",
|
||||
"bv",
|
||||
"curve25519-dalek 2.1.0",
|
||||
"hex",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rustc_version",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-sdk-macro",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84bac623c15acb44f571ec177b67a6434c6aa7637bdb26fe5d776aeb7f4d61ae"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
|
@ -1858,9 +1921,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-runtime"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d511d1dfcf89db6783e83f9f028f139bbff357e190bd0947bd23ff1235f97558"
|
||||
checksum = "8242a732a6db6227854f9bb0c2958c1f219be85989d7ca66d934033d32043c4f"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"blake3",
|
||||
|
@ -1888,12 +1951,13 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-measure",
|
||||
"solana-metrics",
|
||||
"solana-rayon-threadlimit",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-secp256k1-program",
|
||||
"solana-stake-program",
|
||||
"solana-vote-program",
|
||||
|
@ -1906,9 +1970,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e8742ccdaac9ff6e7085e8eb3737858254e4691c6fcaac6b472875db2bbba0d"
|
||||
checksum = "096751fdd2ec2dc3ed7146b1b14245a5b562a21b5046bf3677810a96037aff96"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"bincode",
|
||||
|
@ -1916,7 +1980,6 @@ dependencies = [
|
|||
"bv",
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"curve25519-dalek 2.1.0",
|
||||
"digest 0.9.0",
|
||||
"ed25519-dalek",
|
||||
"generic-array 0.14.4",
|
||||
|
@ -1940,17 +2003,19 @@ dependencies = [
|
|||
"sha2",
|
||||
"sha3",
|
||||
"solana-crate-features",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-program",
|
||||
"solana-sdk-macro",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f38f6c5f3b4119ffa7f75156836e5c88082e557fa978fe1f87995bd386b0d08"
|
||||
checksum = "a02d89c5d8c3c098552e39ad716f8e25b1b9ce95905ad0c770c78d36e1ebcc39"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2 1.0.19",
|
||||
|
@ -1959,24 +2024,11 @@ dependencies = [
|
|||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro-frozen-abi"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e47f618ad2d7af7b9c701e9cc9951681f6d6a9c754863f2ab63e1b98507e515"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-secp256k1-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d8888a924c9183f430a72e1a643648aeff105278bc39315d211bd6b6197e0a0"
|
||||
checksum = "0fa9c6d939374dc10aadb4f5d918134d3388411f8bb975386cd6769afe127268"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"digest 0.9.0",
|
||||
|
@ -1989,9 +2041,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-stake-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3780a14335d07b301128ad518876c8f4c3cb513f88e808faef3ed8a5090abc6"
|
||||
checksum = "1decea030cb64647c3bee685d804344c10de071ec03f0331436c8c90b500ca27"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -2001,18 +2053,19 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-metrics",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-vote-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-vote-program"
|
||||
version = "1.4.1"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "595274785736cbae1f012ed1c78aebbbe2cf75720dec1e1850800c9cd64fae9b"
|
||||
checksum = "b44aeb9a4169443ce3d2ee417fe61abc1067d6d842e609f3ec30e462b98fae45"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -2021,10 +2074,11 @@ dependencies = [
|
|||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-metrics",
|
||||
"solana-sdk",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -2061,7 +2115,7 @@ dependencies = [
|
|||
"num-traits",
|
||||
"num_enum",
|
||||
"remove_dir_all",
|
||||
"solana-sdk",
|
||||
"solana-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ edition = "2018"
|
|||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
spl-token = { path = "../program" }
|
||||
solana-runtime = { version = "1.3.17" }
|
||||
solana-sdk = { version = "1.3.17" }
|
||||
solana-bpf-loader-program = { version = "1.3.17" }
|
||||
spl-token = { path = "../program", features = [ "exclude_entrypoint" ] }
|
||||
solana-runtime = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
||||
solana-bpf-loader-program = "1.4.3"
|
||||
solana_rbpf = "=0.1.32"
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use std::{fs::canonicalize, process::Command};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:warning=(not a warning) Building SPL Token shared object");
|
||||
Command::new(canonicalize("../../do.sh").unwrap())
|
||||
.current_dir("../..")
|
||||
.arg("build")
|
||||
.arg("token/program")
|
||||
println!("cargo:warning=(not a warning) Building BPF token program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build token program")
|
||||
.expect("Failed to build BPF token program")
|
||||
.success();
|
||||
}
|
||||
|
|
|
@ -74,15 +74,15 @@ fn run_program(
|
|||
|
||||
#[test]
|
||||
fn assert_instruction_count() {
|
||||
let program_id = Pubkey::new_rand();
|
||||
let source_key = Pubkey::new_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let source_key = Pubkey::new_unique();
|
||||
let source_account = SolanaAccount::new_ref(u64::MAX, Account::get_packed_len(), &program_id);
|
||||
let destination_key = Pubkey::new_rand();
|
||||
let destination_key = Pubkey::new_unique();
|
||||
let destination_account =
|
||||
SolanaAccount::new_ref(u64::MAX, Account::get_packed_len(), &program_id);
|
||||
let owner_key = Pubkey::new_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let owner_account = RefCell::new(SolanaAccount::default());
|
||||
let mint_key = Pubkey::new_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mint_account = SolanaAccount::new_ref(0, Mint::get_packed_len(), &program_id);
|
||||
let rent_key = rent::id();
|
||||
let rent_account = RefCell::new(rent::create_account(42, &Rent::default()));
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-token-v3"
|
||||
version = "3.0.0"
|
||||
|
@ -12,15 +9,13 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
remove_dir_all = "=0.5.0"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
thiserror = "1.0"
|
||||
arrayref = "0.3.6"
|
||||
num_enum = "0.5.1"
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use crate::{error::TokenError, processor::Processor};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Error types
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the Token program.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Instruction types
|
||||
|
||||
use crate::error::TokenError;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
program_option::COption,
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
|
||||
//! An ERC20-like Token program for the Solana blockchain
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod native_mint;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
pub mod entrypoint;
|
||||
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
/// Convert the UI representation of a token amount (using the decimals field defined in its mint)
|
||||
/// to the raw amount
|
||||
|
@ -25,4 +26,4 @@ pub fn amount_to_ui_amount(amount: u64, decimals: u8) -> f64 {
|
|||
amount as f64 / 10_usize.pow(decimals as u32) as f64
|
||||
}
|
||||
|
||||
solana_sdk::declare_id!("TokenKEGQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||
solana_program::declare_id!("TokenKEGQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
pub const DECIMALS: u8 = 9;
|
||||
|
||||
// The Mint for native SOL Token accounts
|
||||
solana_sdk::declare_id!("So11111111111111111111111111111111111111113");
|
||||
solana_program::declare_id!("So11111111111111111111111111111111111111113");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::native_token::*;
|
||||
use solana_program::native_token::*;
|
||||
|
||||
#[test]
|
||||
fn test_decimals() {
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
//! Program state processor
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
|
||||
use crate::{
|
||||
error::TokenError,
|
||||
instruction::{is_valid_signer_index, AuthorityType, TokenInstruction, MAX_SIGNERS},
|
||||
state::{Account, AccountState, Mint, Multisig},
|
||||
};
|
||||
use num_traits::FromPrimitive;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
decode_error::DecodeError,
|
||||
entrypoint::ProgramResult,
|
||||
|
@ -779,23 +777,15 @@ impl PrintProgramError for TokenError {
|
|||
}
|
||||
}
|
||||
|
||||
// Pull in syscall stubs when building for non-BPF targets
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::instruction::*;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account::Account as SolanaAccount, account_info::create_is_signer_account_infos,
|
||||
clock::Epoch, instruction::Instruction, sysvar::rent,
|
||||
};
|
||||
|
||||
fn pubkey_rand() -> Pubkey {
|
||||
Pubkey::new(&rand::random::<[u8; 32]>())
|
||||
}
|
||||
|
||||
fn do_process_instruction(
|
||||
instruction: Instruction,
|
||||
accounts: Vec<&mut SolanaAccount>,
|
||||
|
@ -967,11 +957,11 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_initialize_mint() {
|
||||
let program_id = pubkey_rand();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account = SolanaAccount::new(42, Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1015,12 +1005,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_initialize_mint_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(42, Account::get_packed_len(), &program_id);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1091,46 +1081,46 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_transfer_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mut account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mut account2_info: AccountInfo = (&account2_key, false, &mut account2_account).into();
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_info: AccountInfo = (&account3_key, false, &mut account3_account).into();
|
||||
let account4_key = pubkey_rand();
|
||||
let account4_key = Pubkey::new_unique();
|
||||
let mut account4_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account4_info: AccountInfo = (&account4_key, true, &mut account4_account).into();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let multisig_info: AccountInfo = (&multisig_key, true, &mut multisig_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -1398,41 +1388,41 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_transfer() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
// create mint
|
||||
|
@ -1728,7 +1718,7 @@ mod tests {
|
|||
// This is probably wrong but transactions in the wild have been observed to do this so
|
||||
// this behavior is now part of the token ABI
|
||||
{
|
||||
let system_account_key = pubkey_rand();
|
||||
let system_account_key = Pubkey::new_unique();
|
||||
let mut system_account = SolanaAccount::new(1, 0, &Pubkey::default());
|
||||
|
||||
let instruction = transfer(
|
||||
|
@ -1897,16 +1887,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mintable_token_with_zero_supply() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1948,7 +1938,7 @@ mod tests {
|
|||
vec![&mut mint_account, &mut account_account, &mut owner_account],
|
||||
)
|
||||
.unwrap();
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 42);
|
||||
|
||||
|
@ -1970,7 +1960,7 @@ mod tests {
|
|||
)
|
||||
);
|
||||
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 42);
|
||||
|
||||
|
@ -1989,46 +1979,46 @@ mod tests {
|
|||
vec![&mut mint_account, &mut account_account, &mut owner_account],
|
||||
)
|
||||
.unwrap();
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 84);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_approve_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_info: AccountInfo = (&account2_key, false, &mut account2_account).into();
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_info: AccountInfo = (&account3_key, true, &mut account3_account).into();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let multisig_info: AccountInfo = (&multisig_key, true, &mut multisig_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -2207,26 +2197,26 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_approve() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -2412,16 +2402,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_set_authority_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -2515,28 +2505,28 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_set_authority() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let owner3_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner3_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -2854,18 +2844,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mint_to_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -2950,40 +2940,40 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mint_to() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let uninitialized_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let uninitialized_key = Pubkey::new_unique();
|
||||
let mut uninitialized_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
|
@ -3153,18 +3143,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_burn_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -3353,41 +3343,41 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_burn() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
// create new mint
|
||||
|
@ -3611,34 +3601,34 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_multisig() {
|
||||
let program_id = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(42, Multisig::get_packed_len(), &program_id);
|
||||
let multisig_delegate_key = pubkey_rand();
|
||||
let multisig_delegate_key = Pubkey::new_unique();
|
||||
let mut multisig_delegate_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let signer_keys = vec![pubkey_rand(); MAX_SIGNERS];
|
||||
let signer_key_refs: Vec<&Pubkey> = signer_keys.iter().map(|key| key).collect();
|
||||
let signer_keys = vec![Pubkey::new_unique(); MAX_SIGNERS];
|
||||
let signer_key_refs: Vec<&Pubkey> = signer_keys.iter().collect();
|
||||
let mut signer_accounts = vec![SolanaAccount::new(0, 0, &program_id); MAX_SIGNERS];
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -3903,13 +3893,13 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
// freeze account
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
do_process_instruction(
|
||||
|
@ -4015,11 +4005,11 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_validate_owner() {
|
||||
let program_id = pubkey_rand();
|
||||
let owner_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut signer_keys = [Pubkey::default(); MAX_SIGNERS];
|
||||
for signer_key in signer_keys.iter_mut().take(MAX_SIGNERS) {
|
||||
*signer_key = pubkey_rand();
|
||||
*signer_key = Pubkey::new_unique();
|
||||
}
|
||||
let mut signer_lamports = 0;
|
||||
let mut signer_data = vec![];
|
||||
|
@ -4175,23 +4165,23 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_close_account_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_info: AccountInfo = (&account2_key, true, &mut account2_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -4261,31 +4251,31 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_close_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance() + 42,
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -4402,13 +4392,13 @@ mod tests {
|
|||
assert_eq!(account.amount, 0);
|
||||
|
||||
// fund and initialize new non-native account to test close authority
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
|
@ -4490,24 +4480,24 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_native_token() {
|
||||
let program_id = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance() + 40,
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(account_minimum_balance(), 0, &program_id);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -4571,7 +4561,7 @@ mod tests {
|
|||
);
|
||||
|
||||
// burn unsupported
|
||||
let bogus_mint_key = pubkey_rand();
|
||||
let bogus_mint_key = Pubkey::new_unique();
|
||||
let mut bogus_mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
do_process_instruction(
|
||||
|
@ -4667,26 +4657,26 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_overflow() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_owner_key = pubkey_rand();
|
||||
let mint_owner_key = Pubkey::new_unique();
|
||||
let mut mint_owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -4844,22 +4834,22 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_frozen() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -4956,7 +4946,7 @@ mod tests {
|
|||
let mut account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
account.state = AccountState::Frozen;
|
||||
Account::pack(account, &mut account_account.data).unwrap();
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
assert_eq!(
|
||||
Err(TokenError::AccountFrozen.into()),
|
||||
|
@ -4992,7 +4982,7 @@ mod tests {
|
|||
);
|
||||
|
||||
// no set authority if account is frozen
|
||||
let new_owner_key = pubkey_rand();
|
||||
let new_owner_key = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(TokenError::AccountFrozen.into()),
|
||||
do_process_instruction(
|
||||
|
@ -5030,16 +5020,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_freeze_thaw_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -5094,20 +5084,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_freeze_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account_owner_key = pubkey_rand();
|
||||
let account_owner_key = Pubkey::new_unique();
|
||||
let mut account_owner_account = SolanaAccount::default();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use crate::instruction::MAX_SIGNERS;
|
||||
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
|
||||
use num_enum::TryFromPrimitive;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
program_error::ProgramError,
|
||||
program_option::COption,
|
||||
program_pack::{IsInitialized, Pack, Sealed},
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "spl-token"
|
||||
version = "2.0.8"
|
||||
|
@ -12,21 +9,18 @@ edition = "2018"
|
|||
exclude = ["js/**"]
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["solana-sdk/default"]
|
||||
exclude_entrypoint = []
|
||||
|
||||
[dependencies]
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
remove_dir_all = "=0.5.0"
|
||||
solana-sdk = { version = "1.3.17", default-features = false, optional = true }
|
||||
solana-program = "1.4.3"
|
||||
thiserror = "1.0"
|
||||
arrayref = "0.3.6"
|
||||
num_enum = "0.5.1"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
//! Program entrypoint
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
#![cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
use crate::{error::TokenError, processor::Processor};
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
||||
program_error::PrintProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Error types
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use solana_sdk::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that may be returned by the Token program.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Instruction types
|
||||
|
||||
use crate::error::TokenError;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
program_option::COption,
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
|
||||
//! An ERC20-like Token program for the Solana blockchain
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
pub mod native_mint;
|
||||
pub mod processor;
|
||||
pub mod state;
|
||||
|
||||
// Export current solana-sdk types for downstream users who may also be building with a different
|
||||
// solana-sdk version
|
||||
pub use solana_sdk;
|
||||
#[cfg(not(feature = "exclude_entrypoint"))]
|
||||
mod entrypoint;
|
||||
|
||||
// Export current sdk types for downstream users building with a different sdk version
|
||||
pub use solana_program;
|
||||
|
||||
/// Convert the UI representation of a token amount (using the decimals field defined in its mint)
|
||||
/// to the raw amount
|
||||
|
@ -25,4 +26,4 @@ pub fn amount_to_ui_amount(amount: u64, decimals: u8) -> f64 {
|
|||
amount as f64 / 10_usize.pow(decimals as u32) as f64
|
||||
}
|
||||
|
||||
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||
solana_program::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
pub const DECIMALS: u8 = 9;
|
||||
|
||||
// The Mint for native SOL Token accounts
|
||||
solana_sdk::declare_id!("So11111111111111111111111111111111111111112");
|
||||
solana_program::declare_id!("So11111111111111111111111111111111111111112");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::native_token::*;
|
||||
use solana_program::native_token::*;
|
||||
|
||||
#[test]
|
||||
fn test_decimals() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Program state processor
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
//#![cfg(feature = "program")]
|
||||
|
||||
use crate::{
|
||||
error::TokenError,
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||
state::{Account, AccountState, Mint, Multisig},
|
||||
};
|
||||
use num_traits::FromPrimitive;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account_info::{next_account_info, AccountInfo},
|
||||
decode_error::DecodeError,
|
||||
entrypoint::ProgramResult,
|
||||
|
@ -780,23 +780,15 @@ impl PrintProgramError for TokenError {
|
|||
}
|
||||
}
|
||||
|
||||
// Pull in syscall stubs when building for non-BPF targets
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
solana_sdk::program_stubs!();
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::instruction::*;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
account::Account as SolanaAccount, account_info::create_is_signer_account_infos,
|
||||
clock::Epoch, instruction::Instruction, sysvar::rent,
|
||||
};
|
||||
|
||||
fn pubkey_rand() -> Pubkey {
|
||||
Pubkey::new(&rand::random::<[u8; 32]>())
|
||||
}
|
||||
|
||||
fn do_process_instruction(
|
||||
instruction: Instruction,
|
||||
accounts: Vec<&mut SolanaAccount>,
|
||||
|
@ -968,11 +960,11 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_initialize_mint() {
|
||||
let program_id = pubkey_rand();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account = SolanaAccount::new(42, Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1016,12 +1008,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_initialize_mint_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(42, Account::get_packed_len(), &program_id);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1092,46 +1084,46 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_transfer_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mut account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mut account2_info: AccountInfo = (&account2_key, false, &mut account2_account).into();
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_info: AccountInfo = (&account3_key, false, &mut account3_account).into();
|
||||
let account4_key = pubkey_rand();
|
||||
let account4_key = Pubkey::new_unique();
|
||||
let mut account4_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account4_info: AccountInfo = (&account4_key, true, &mut account4_account).into();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let multisig_info: AccountInfo = (&multisig_key, true, &mut multisig_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -1399,41 +1391,41 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_transfer() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
// create mint
|
||||
|
@ -1729,7 +1721,7 @@ mod tests {
|
|||
// This is probably wrong but transactions in the wild have been observed to do this so
|
||||
// this behavior is now part of the token ABI
|
||||
{
|
||||
let system_account_key = pubkey_rand();
|
||||
let system_account_key = Pubkey::new_unique();
|
||||
let mut system_account = SolanaAccount::new(1, 0, &Pubkey::default());
|
||||
|
||||
let instruction = transfer(
|
||||
|
@ -1898,16 +1890,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mintable_token_with_zero_supply() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -1949,7 +1941,7 @@ mod tests {
|
|||
vec![&mut mint_account, &mut account_account, &mut owner_account],
|
||||
)
|
||||
.unwrap();
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 42);
|
||||
|
||||
|
@ -1971,7 +1963,7 @@ mod tests {
|
|||
)
|
||||
);
|
||||
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 42);
|
||||
|
||||
|
@ -1990,46 +1982,46 @@ mod tests {
|
|||
vec![&mut mint_account, &mut account_account, &mut owner_account],
|
||||
)
|
||||
.unwrap();
|
||||
let _ = Mint::unpack(&mut mint_account.data).unwrap();
|
||||
let _ = Mint::unpack(&mint_account.data).unwrap();
|
||||
let account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
assert_eq!(account.amount, 84);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_approve_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_info: AccountInfo = (&account2_key, false, &mut account2_account).into();
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_info: AccountInfo = (&account3_key, true, &mut account3_account).into();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let multisig_info: AccountInfo = (&multisig_key, true, &mut multisig_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -2208,26 +2200,26 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_approve() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -2413,16 +2405,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_set_authority_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -2516,28 +2508,28 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_set_authority() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let owner3_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner3_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -2855,18 +2847,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mint_to_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -2951,40 +2943,40 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mint_to() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let uninitialized_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let uninitialized_key = Pubkey::new_unique();
|
||||
let mut uninitialized_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
|
@ -3154,18 +3146,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_burn_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner_info: AccountInfo = (&owner_key, true, &mut owner_account).into();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -3354,41 +3346,41 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_burn() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
let mismatch_key = pubkey_rand();
|
||||
let mismatch_key = Pubkey::new_unique();
|
||||
let mut mismatch_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
// create new mint
|
||||
|
@ -3619,34 +3611,34 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_multisig() {
|
||||
let program_id = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let multisig_key = pubkey_rand();
|
||||
let multisig_key = Pubkey::new_unique();
|
||||
let mut multisig_account = SolanaAccount::new(42, Multisig::get_packed_len(), &program_id);
|
||||
let multisig_delegate_key = pubkey_rand();
|
||||
let multisig_delegate_key = Pubkey::new_unique();
|
||||
let mut multisig_delegate_account = SolanaAccount::new(
|
||||
multisig_minimum_balance(),
|
||||
Multisig::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let signer_keys = vec![pubkey_rand(); MAX_SIGNERS];
|
||||
let signer_key_refs: Vec<&Pubkey> = signer_keys.iter().map(|key| key).collect();
|
||||
let signer_keys = vec![Pubkey::new_unique(); MAX_SIGNERS];
|
||||
let signer_key_refs: Vec<&Pubkey> = signer_keys.iter().collect();
|
||||
let mut signer_accounts = vec![SolanaAccount::new(0, 0, &program_id); MAX_SIGNERS];
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -3911,13 +3903,13 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
// freeze account
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let mint2_key = pubkey_rand();
|
||||
let mint2_key = Pubkey::new_unique();
|
||||
let mut mint2_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
do_process_instruction(
|
||||
|
@ -4023,11 +4015,11 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_validate_owner() {
|
||||
let program_id = pubkey_rand();
|
||||
let owner_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut signer_keys = [Pubkey::default(); MAX_SIGNERS];
|
||||
for signer_key in signer_keys.iter_mut().take(MAX_SIGNERS) {
|
||||
*signer_key = pubkey_rand();
|
||||
*signer_key = Pubkey::new_unique();
|
||||
}
|
||||
let mut signer_lamports = 0;
|
||||
let mut signer_data = vec![];
|
||||
|
@ -4183,23 +4175,23 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_close_account_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_info: AccountInfo = (&account2_key, true, &mut account2_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, false, &mut mint_account).into();
|
||||
|
@ -4269,31 +4261,31 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_close_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance() + 42,
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -4410,13 +4402,13 @@ mod tests {
|
|||
assert_eq!(account.amount, 0);
|
||||
|
||||
// fund and initialize new non-native account to test close authority
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
|
@ -4498,24 +4490,24 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_native_token() {
|
||||
let program_id = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let account_key = pubkey_rand();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance() + 40,
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account3_key = pubkey_rand();
|
||||
let account3_key = Pubkey::new_unique();
|
||||
let mut account3_account = SolanaAccount::new(account_minimum_balance(), 0, &program_id);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
||||
|
@ -4579,7 +4571,7 @@ mod tests {
|
|||
);
|
||||
|
||||
// burn unsupported
|
||||
let bogus_mint_key = pubkey_rand();
|
||||
let bogus_mint_key = Pubkey::new_unique();
|
||||
let mut bogus_mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
do_process_instruction(
|
||||
|
@ -4675,26 +4667,26 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_overflow() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_owner_key = pubkey_rand();
|
||||
let mint_owner_key = Pubkey::new_unique();
|
||||
let mut mint_owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -4852,22 +4844,22 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_frozen() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account2_key = pubkey_rand();
|
||||
let account2_key = Pubkey::new_unique();
|
||||
let mut account2_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
@ -4964,7 +4956,7 @@ mod tests {
|
|||
let mut account = Account::unpack_unchecked(&account_account.data).unwrap();
|
||||
account.state = AccountState::Frozen;
|
||||
Account::pack(account, &mut account_account.data).unwrap();
|
||||
let delegate_key = pubkey_rand();
|
||||
let delegate_key = Pubkey::new_unique();
|
||||
let mut delegate_account = SolanaAccount::default();
|
||||
assert_eq!(
|
||||
Err(TokenError::AccountFrozen.into()),
|
||||
|
@ -5000,7 +4992,7 @@ mod tests {
|
|||
);
|
||||
|
||||
// no set authority if account is frozen
|
||||
let new_owner_key = pubkey_rand();
|
||||
let new_owner_key = Pubkey::new_unique();
|
||||
assert_eq!(
|
||||
Err(TokenError::AccountFrozen.into()),
|
||||
do_process_instruction(
|
||||
|
@ -5038,16 +5030,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_freeze_thaw_dups() {
|
||||
let program_id = pubkey_rand();
|
||||
let account1_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account1_key = Pubkey::new_unique();
|
||||
let mut account1_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account1_info: AccountInfo = (&account1_key, true, &mut account1_account).into();
|
||||
let owner_key = pubkey_rand();
|
||||
let mint_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mint_info: AccountInfo = (&mint_key, true, &mut mint_account).into();
|
||||
|
@ -5102,20 +5094,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_freeze_account() {
|
||||
let program_id = pubkey_rand();
|
||||
let account_key = pubkey_rand();
|
||||
let program_id = Pubkey::new_unique();
|
||||
let account_key = Pubkey::new_unique();
|
||||
let mut account_account = SolanaAccount::new(
|
||||
account_minimum_balance(),
|
||||
Account::get_packed_len(),
|
||||
&program_id,
|
||||
);
|
||||
let account_owner_key = pubkey_rand();
|
||||
let account_owner_key = Pubkey::new_unique();
|
||||
let mut account_owner_account = SolanaAccount::default();
|
||||
let owner_key = pubkey_rand();
|
||||
let owner_key = Pubkey::new_unique();
|
||||
let mut owner_account = SolanaAccount::default();
|
||||
let owner2_key = pubkey_rand();
|
||||
let owner2_key = Pubkey::new_unique();
|
||||
let mut owner2_account = SolanaAccount::default();
|
||||
let mint_key = pubkey_rand();
|
||||
let mint_key = Pubkey::new_unique();
|
||||
let mut mint_account =
|
||||
SolanaAccount::new(mint_minimum_balance(), Mint::get_packed_len(), &program_id);
|
||||
let mut rent_sysvar = rent_sysvar();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use crate::instruction::MAX_SIGNERS;
|
||||
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
|
||||
use num_enum::TryFromPrimitive;
|
||||
use solana_sdk::{
|
||||
use solana_program::{
|
||||
program_error::ProgramError,
|
||||
program_option::COption,
|
||||
program_pack::{IsInitialized, Pack, Sealed},
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Updates the solana version in all the SPL crates
|
||||
#
|
||||
|
||||
solana_ver=$1
|
||||
if [[ -z $solana_ver ]]; then
|
||||
echo "Usage: $0 <new-solana-version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
declare tomls=()
|
||||
while IFS='' read -r line; do tomls+=("$line"); done < <(find . -name Cargo.toml)
|
||||
|
||||
crates=(
|
||||
solana-account-decoder
|
||||
solana-banks-client
|
||||
solana-banks-server
|
||||
solana-bpf-loader-program
|
||||
solana-clap-utils
|
||||
solana-cli-config
|
||||
solana-cli-output
|
||||
solana-client
|
||||
solana-core
|
||||
solana-logger
|
||||
solana-program
|
||||
solana-runtime
|
||||
solana-sdk
|
||||
)
|
||||
|
||||
set -x
|
||||
for crate in "${crates[@]}"; do
|
||||
sed -i -e "s#\(${crate} = \"\).*\(\"\)#\1$solana_ver\2#g" "${tomls[@]}"
|
||||
done
|
||||
|
||||
#sed -i -e "s#\(solana-sdk = { version = \"\).*\(\"\)#\1$solana_ver\2#g" "${tomls[@]}"
|
||||
#sed -i -e "s#\(solana-client = \"\).*\(\"\)#\1$solana_ver\2#g" "${tomls[@]}"
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ edition = "2018"
|
|||
# Used to ensure that SPL programs are buildable by external clients
|
||||
|
||||
[dependencies]
|
||||
solana-sdk = "1.3.11"
|
||||
spl-memo = { path = "../../memo/program" }
|
||||
spl-token = { path = "../../token/program" }
|
||||
spl-token-v3 = { path = "../../token/program-v3" }
|
||||
spl-token-swap = { path = "../../token-swap/program" }
|
||||
solana-sdk = "1.4.3"
|
||||
spl-memo = { path = "../../memo/program", features = [ "exclude_entrypoint" ] }
|
||||
spl-token = { path = "../../token/program", features = [ "exclude_entrypoint" ] }
|
||||
spl-token-swap = { path = "../../token-swap/program", features = [ "exclude_entrypoint" ] }
|
||||
spl-token-v3 = { path = "../../token/program-v3", features = [ "exclude_entrypoint" ] }
|
||||
|
|
Loading…
Reference in New Issue