File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ incremented for features.
1919* lang/attribute/access-control: Allow specifying multiple modifier functions ([ 845df6] ( https://github.com/project-serum/anchor/commit/845df6d1960bb544fa0f2e3331ec79cc804edeb6 ) ).
2020* lang/syn: Allow state structs that don't have a ctor or impl block (just trait implementations) ([ a78000] ( https://github.com/project-serum/anchor/commit/a7800026833d64579e5b19c90d724ecc20d2a455 ) ).
2121* ts: Add instruction method to state namespace ([ 627c27] ( https://github.com/project-serum/anchor/commit/627c275e9cdf3dafafcf44473ba8146cc7979d44 ) ).
22+ * lang/syn, ts: Add support for u128 and i128 ([ #83 ] ( https://github.com/project-serum/anchor/pull/83 ) ).
2223
2324## [ 0.2.0] - 2021-02-08
2425
Original file line number Diff line number Diff line change 1+ cluster = " localnet"
2+ wallet = " /home/armaniferrante/.config/solana/id.json"
Original file line number Diff line number Diff line change 1+ [workspace ]
2+ members = [
3+ " programs/*"
4+ ]
Original file line number Diff line number Diff line change 1+
2+ // Migrations are an early feature. Currently, they're nothing more than this
3+ // single deploy script that's invoked from the CLI, injecting a provider
4+ // configured from the workspace's Anchor.toml.
5+
6+ const anchor = require ( "@project-serum/anchor" ) ;
7+
8+ module . exports = async function ( provider ) {
9+ // Configure client to use the provider.
10+ anchor . setProvider ( provider ) ;
11+
12+ // Add your deploy script here.
13+ }
Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " misc"
3+ version = " 0.1.0"
4+ description = " Created with Anchor"
5+ edition = " 2018"
6+
7+ [lib ]
8+ crate-type = [" cdylib" , " lib" ]
9+ name = " misc"
10+
11+ [features ]
12+ no-entrypoint = []
13+ no-idl = []
14+ cpi = [" no-entrypoint" ]
15+ default = []
16+
17+ [dependencies ]
18+ anchor-lang = { git = " https://github.com/project-serum/anchor" , features = [" derive" ] }
Original file line number Diff line number Diff line change 1+ [target .bpfel-unknown-unknown .dependencies .std ]
2+ features = []
Original file line number Diff line number Diff line change 1+ //! Misc example is a catchall program for testing unrelated features.
2+ //! It's not too instructive/coherent by itself, so please see other examples.
3+
4+ #![ feature( proc_macro_hygiene) ]
5+
6+ use anchor_lang:: prelude:: * ;
7+
8+ #[ program]
9+ pub mod misc {
10+ use super :: * ;
11+ pub fn initialize ( ctx : Context < Initialize > , udata : u128 , idata : i128 ) -> ProgramResult {
12+ ctx. accounts . data . udata = udata;
13+ ctx. accounts . data . idata = idata;
14+ Ok ( ( ) )
15+ }
16+ }
17+
18+ #[ derive( Accounts ) ]
19+ pub struct Initialize < ' info > {
20+ #[ account( init) ]
21+ data : ProgramAccount < ' info , Data > ,
22+ rent : Sysvar < ' info , Rent > ,
23+ }
24+
25+ #[ account]
26+ pub struct Data {
27+ udata : u128 ,
28+ idata : i128 ,
29+ }
Original file line number Diff line number Diff line change 1+ const anchor = require ( '@project-serum/anchor' ) ;
2+ const assert = require ( "assert" ) ;
3+
4+ describe ( "misc" , ( ) => {
5+ // Configure the client to use the local cluster.
6+ anchor . setProvider ( anchor . Provider . env ( ) ) ;
7+
8+ it ( "Can use u128 and i128" , async ( ) => {
9+ const data = new anchor . web3 . Account ( ) ;
10+ const program = anchor . workspace . Misc ;
11+ const tx = await program . rpc . initialize (
12+ new anchor . BN ( 1234 ) ,
13+ new anchor . BN ( 22 ) ,
14+ {
15+ accounts : {
16+ data : data . publicKey ,
17+ rent : anchor . web3 . SYSVAR_RENT_PUBKEY ,
18+ } ,
19+ signers : [ data ] ,
20+ instructions : [ await program . account . data . createInstruction ( data ) ] ,
21+ }
22+ ) ;
23+ const dataAccount = await program . account . data ( data . publicKey ) ;
24+ assert . ok ( dataAccount . udata . eq ( new anchor . BN ( 1234 ) ) ) ;
25+ assert . ok ( dataAccount . idata . eq ( new anchor . BN ( 22 ) ) ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ pub enum IdlType {
104104 I32 ,
105105 U64 ,
106106 I64 ,
107+ U128 ,
108+ I128 ,
107109 Bytes ,
108110 String ,
109111 PublicKey ,
@@ -133,6 +135,8 @@ impl std::str::FromStr for IdlType {
133135 "i32" => IdlType :: I32 ,
134136 "u64" => IdlType :: U64 ,
135137 "i64" => IdlType :: I64 ,
138+ "u128" => IdlType :: U128 ,
139+ "i128" => IdlType :: I128 ,
136140 "Vec<u8>" => IdlType :: Bytes ,
137141 "String" => IdlType :: String ,
138142 "Pubkey" => IdlType :: PublicKey ,
Original file line number Diff line number Diff line change 2323 "prepublishOnly" : " yarn build"
2424 },
2525 "dependencies" : {
26- "@project-serum/borsh" : " ^0.0.1-beta .0" ,
26+ "@project-serum/borsh" : " ^0.1 .0" ,
2727 "@solana/web3.js" : " ^0.90.4" ,
2828 "@types/bn.js" : " ^4.11.6" ,
2929 "@types/bs58" : " ^4.0.1" ,
You can’t perform that action at this time.
0 commit comments