-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,936 additions
and
1,271 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
runtime/near-vm/tests/lib/compiler-test-derive/src/lib.rs.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+256 KB
(410%)
runtime/near-wallet-contract/res/nightly_wallet_contract.wasm
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,26 @@ | ||
[package] | ||
name = "wallet-contract" | ||
version = "0.1.0" | ||
authors = ["Near Inc <[email protected]>"] | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
description = "A placeholder implementation of the Wallet Contract." | ||
repository.workspace = true | ||
license.workspace = true | ||
publish = false | ||
edition = "2021" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
base64 = "0.21" | ||
serde_json = "1" | ||
near-sdk = "4.1.1" | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
# Tell `rustc` to optimize for small code size. | ||
opt-level = "z" | ||
strip = true | ||
lto = true | ||
debug = false | ||
panic = "abort" | ||
rpath = false | ||
debug-assertions = false | ||
incremental = false | ||
|
||
[workspace] | ||
members = [] | ||
base64.workspace = true | ||
hex.workspace = true | ||
serde_json.workspace = true | ||
near-sdk.workspace = true | ||
rlp.workspace = true | ||
|
||
[features] | ||
nightly = [] | ||
latest_protocol = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
//! Temporary implementation of the Wallet Contract. | ||
//! See https://github.com/near/NEPs/issues/518. | ||
//! Must not use in production! | ||
|
||
// TODO(eth-implicit) Change to a real Wallet Contract implementation. | ||
|
||
use hex; | ||
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; | ||
use near_sdk::{near_bindgen, AccountId, Promise, Balance}; | ||
use near_sdk::{env, near_bindgen, AccountId, Promise}; | ||
use rlp::Rlp; | ||
|
||
#[near_bindgen] | ||
#[derive(Default, BorshDeserialize, BorshSerialize)] | ||
pub struct WalletContract { } | ||
pub struct WalletContract {} | ||
|
||
#[near_bindgen] | ||
impl WalletContract { | ||
pub fn transfer(&self, to: AccountId, amount: Balance){ | ||
Promise::new(to).transfer(amount); | ||
} | ||
pub fn execute_rlp(&self, target: AccountId, rlp_transaction: Vec<u8>) { | ||
let rlp = Rlp::new(&rlp_transaction); | ||
|
||
let to: String = match rlp.val_at(0) { | ||
Ok(to) => to, | ||
_ => env::panic_str("Missing `to` field in RLP-encoded transaction."), | ||
}; | ||
if target.to_string() != to { | ||
env::panic_str("`target` equals the transaction's `To` address."); | ||
} | ||
|
||
let value_bytes: Vec<u8> = match rlp.val_at(1) { | ||
Ok(value_bytes) => value_bytes, | ||
_ => env::panic_str("Missing `value` field in RLP-encoded transaction."), | ||
}; | ||
let value = u128::from_be_bytes( | ||
value_bytes.try_into().expect("Incorrect `value` field in RLP-encoded transaction."), | ||
); | ||
|
||
let signer_public_key_bytes: Vec<u8> = match rlp.val_at(2) { | ||
Ok(signer_public_key_bytes) => signer_public_key_bytes, | ||
_ => env::panic_str("Signature extraction failed for RLP-encoded transaction."), | ||
}; | ||
|
||
let hash = env::keccak256(&signer_public_key_bytes); | ||
let signer_address = format!("0x{}", hex::encode(&hash[12..32])); | ||
|
||
if signer_address != env::current_account_id().to_string() { | ||
env::panic_str("Public key does not match the Wallet Contract address."); | ||
} | ||
|
||
Promise::new(target).transfer(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters