Browse Source

lang, ts: Consistent domain delimiters (#321)

Armani Ferrante 4 years ago
parent
commit
21fc2d15f4

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@ incremented for features.
 ## Breaking Changes
 ## 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: `#[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
 ## [0.6.0] - 2021-05-23
 
 

+ 2 - 2
examples/ido-pool/programs/ido-pool/Cargo.toml

@@ -15,5 +15,5 @@ cpi = ["no-entrypoint"]
 default = []
 default = []
 
 
 [dependencies]
 [dependencies]
-anchor-lang = "0.4.4"
-anchor-spl = "0.4.4"
+anchor-lang = { path = "../../../../lang" }
+anchor-spl = { path = "../../../../spl" }

+ 1 - 1
examples/pyth/programs/pyth/Cargo.toml

@@ -15,6 +15,6 @@ cpi = ["no-entrypoint"]
 default = []
 default = []
 
 
 [dependencies]
 [dependencies]
-anchor-lang = "0.5.0"
+anchor-lang = { path = "../../../../lang" }
 arrayref = "0.3.6"
 arrayref = "0.3.6"
 bytemuck = { version = "1.4.0" }
 bytemuck = { version = "1.4.0" }

+ 2 - 2
lang/syn/src/codegen/program.rs

@@ -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
 // However, we do namespace methods in the preeimage so that we can use
 // different traits with the same method name.
 // different traits with the same method name.
 pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {
 pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {
-    let preimage = format!("{}::{}", namespace, name);
+    let preimage = format!("{}:{}", namespace, name);
 
 
     let mut sighash = [0u8; 8];
     let mut sighash = [0u8; 8];
     sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);
     sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);
@@ -1371,7 +1371,7 @@ pub fn sighash(namespace: &str, name: &str) -> [u8; 8] {
 
 
 fn sighash_ctor() -> [u8; 8] {
 fn sighash_ctor() -> [u8; 8] {
     let namespace = SIGHASH_STATE_NAMESPACE;
     let namespace = SIGHASH_STATE_NAMESPACE;
-    let preimage = format!("{}::new", namespace);
+    let preimage = format!("{}:new", namespace);
 
 
     let mut sighash = [0u8; 8];
     let mut sighash = [0u8; 8];
     sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);
     sighash.copy_from_slice(&crate::hash::hash(preimage.as_bytes()).to_bytes()[..8]);

+ 1 - 1
ts/src/coder.ts

@@ -566,7 +566,7 @@ export function accountSize(
 // doesn't allow function overloading.
 // doesn't allow function overloading.
 function sighash(nameSpace: string, ixName: string): Buffer {
 function sighash(nameSpace: string, ixName: string): Buffer {
   let name = snakeCase(ixName);
   let name = snakeCase(ixName);
-  let preimage = `${nameSpace}::${name}`;
+  let preimage = `${nameSpace}:${name}`;
   // @ts-ignore
   // @ts-ignore
   return Buffer.from(sha256.digest(preimage)).slice(0, 8);
   return Buffer.from(sha256.digest(preimage)).slice(0, 8);
 }
 }