Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang, ts: Consistent domain delimiters #321

Merged
merged 4 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ incremented for features.
## Breaking Changes

* lang: `#[account(associated)]` now requires `init` to be provided to create an associated account. If not provided, then the address will be assumed to exist, and a constraint will be added to ensure its correctness ([#318](https://github.com/project-serum/anchor/pull/318)).
* lang, ts: Change domain delimiters for the pre-image of the instruciton sighash to be a single colon `:` to be consistent with accounts. This change should only be noticed by library maintainers.

## [0.6.0] - 2021-05-23

Expand Down
4 changes: 2 additions & 2 deletions examples/ido-pool/programs/ido-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.4.4"
anchor-spl = "0.4.4"
anchor-lang = { path = "../../../../lang" }
anchor-spl = { path = "../../../../spl" }
2 changes: 1 addition & 1 deletion examples/pyth/programs/pyth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.5.0"
anchor-lang = { path = "../../../../lang" }
arrayref = "0.3.6"
bytemuck = { version = "1.4.0" }
4 changes: 2 additions & 2 deletions lang/syn/src/codegen/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ fn generate_cpi(program: &Program) -> proc_macro2::TokenStream {
// However, we do namespace methods in the preeimage so that we can use
// different traits with the same method name.
pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {
let preimage = format!("{}::{}", namespace, name);
let preimage = format!("{}:{}", namespace, name);

let mut sighash = [0u8; 8];
sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);
Expand All @@ -1371,7 +1371,7 @@ pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {

fn sighash_ctor() -> [u8; 8] {
let namespace = SIGHASH_STATE_NAMESPACE;
let preimage = format!("{}::new", namespace);
let preimage = format!("{}:new", namespace);

let mut sighash = [0u8; 8];
sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);
Expand Down
2 changes: 1 addition & 1 deletion ts/src/coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ export function accountSize(
// doesn't allow function overloading.
function sighash(nameSpace: string, ixName: string): Buffer {
let name = snakeCase(ixName);
let preimage = `${nameSpace}::${name}`;
let preimage = `${nameSpace}:${name}`;
// @ts-ignore
return Buffer.from(sha256.digest(preimage)).slice(0, 8);
}