@@ -126,24 +126,75 @@ describe("SigningCosmWasmClient", () => {
126126 client . disconnect ( ) ;
127127 } ) ;
128128
129- it ( "works with legacy Amino signer access type " , async ( ) => {
129+ it ( "works with Amino JSON signer " , async ( ) => {
130130 pendingWithoutWasmd ( ) ;
131- pending ( "wasmd 0.50 does not work with Amino JSON signing" ) ;
132131 const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
133- const options = { ...defaultSigningClientOptions , prefix : wasmd . prefix } ;
134- const client = await SigningCosmWasmClient . connectWithSigner ( wasmd . endpoint , wallet , options ) ;
132+ const client = await SigningCosmWasmClient . connectWithSigner (
133+ wasmd . endpoint ,
134+ wallet ,
135+ defaultSigningClientOptions ,
136+ ) ;
137+ const wasm = getHackatom ( ) . data ;
138+ const { codeId, checksum, originalSize, compressedSize } = await client . upload (
139+ alice . address0 ,
140+ wasm ,
141+ defaultUploadFee ,
142+ ) ;
143+ expect ( checksum ) . toEqual ( toHex ( sha256 ( wasm ) ) ) ;
144+ expect ( originalSize ) . toEqual ( wasm . length ) ;
145+ expect ( compressedSize ) . toBeLessThan ( wasm . length * 0.5 ) ;
146+ expect ( codeId ) . toBeGreaterThanOrEqual ( 1 ) ;
147+ client . disconnect ( ) ;
148+ } ) ;
149+
150+ it ( "works with Amino JSON signer (instantiatePermission set to one address)" , async ( ) => {
151+ pending ( "Known issue: https://github.com/CosmWasm/wasmd/issues/1863" ) ;
152+ pendingWithoutWasmd ( ) ;
153+ const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
154+ const client = await SigningCosmWasmClient . connectWithSigner (
155+ wasmd . endpoint ,
156+ wallet ,
157+ defaultSigningClientOptions ,
158+ ) ;
159+ const wasm = getHackatom ( ) . data ;
160+ const instantiatePermission = AccessConfig . fromPartial ( {
161+ permission : AccessType . ACCESS_TYPE_ANY_OF_ADDRESSES ,
162+ addresses : [ makeRandomAddress ( ) ] ,
163+ } ) ;
164+ const { codeId, checksum, originalSize, compressedSize } = await client . upload (
165+ alice . address0 ,
166+ wasm ,
167+ defaultUploadFee ,
168+ "test memo" ,
169+ instantiatePermission ,
170+ ) ;
171+ expect ( checksum ) . toEqual ( toHex ( sha256 ( wasm ) ) ) ;
172+ expect ( originalSize ) . toEqual ( wasm . length ) ;
173+ expect ( compressedSize ) . toBeLessThan ( wasm . length * 0.5 ) ;
174+ expect ( codeId ) . toBeGreaterThanOrEqual ( 1 ) ;
175+ client . disconnect ( ) ;
176+ } ) ;
177+
178+ it ( "works with Amino JSON signer (instantiatePermission set to everybody)" , async ( ) => {
179+ pending ( "Known issue: https://github.com/CosmWasm/wasmd/issues/1863" ) ;
180+ pendingWithoutWasmd ( ) ;
181+ const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
182+ const client = await SigningCosmWasmClient . connectWithSigner (
183+ wasmd . endpoint ,
184+ wallet ,
185+ defaultSigningClientOptions ,
186+ ) ;
135187 const wasm = getHackatom ( ) . data ;
136- const accessConfig : AccessConfig = {
188+ const instantiatePermission = AccessConfig . fromPartial ( {
137189 permission : AccessType . ACCESS_TYPE_EVERYBODY ,
138- address : "" ,
139190 addresses : [ ] ,
140- } ;
191+ } ) ;
141192 const { codeId, checksum, originalSize, compressedSize } = await client . upload (
142193 alice . address0 ,
143194 wasm ,
144195 defaultUploadFee ,
145196 "test memo" ,
146- accessConfig ,
197+ instantiatePermission ,
147198 ) ;
148199 expect ( checksum ) . toEqual ( toHex ( sha256 ( wasm ) ) ) ;
149200 expect ( originalSize ) . toEqual ( wasm . length ) ;
@@ -262,17 +313,17 @@ describe("SigningCosmWasmClient", () => {
262313 client . disconnect ( ) ;
263314 } ) ;
264315
265- it ( "works with legacy Amino signer" , async ( ) => {
316+ it ( "works with Amino JSON signer" , async ( ) => {
266317 pendingWithoutWasmd ( ) ;
267- pending ( "wasmd 0.50 does not work with Amino JSON signing" ) ;
268318 const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
269319 const client = await SigningCosmWasmClient . connectWithSigner (
270320 wasmd . endpoint ,
271321 wallet ,
272322 defaultSigningClientOptions ,
273323 ) ;
324+ const funds = [ coin ( 1234 , "ucosm" ) , coin ( 321 , "ustake" ) ] ;
274325
275- // With admin
326+ // Without admin
276327 await client . instantiate (
277328 alice . address0 ,
278329 deployedHackatom . codeId ,
@@ -282,10 +333,13 @@ describe("SigningCosmWasmClient", () => {
282333 } ,
283334 "contract 1" ,
284335 defaultInstantiateFee ,
285- { admin : makeRandomAddress ( ) } ,
336+ {
337+ funds : funds ,
338+ memo : "instantiate it" ,
339+ } ,
286340 ) ;
287341
288- // Without admin
342+ // With admin
289343 await client . instantiate (
290344 alice . address0 ,
291345 deployedHackatom . codeId ,
@@ -295,6 +349,10 @@ describe("SigningCosmWasmClient", () => {
295349 } ,
296350 "contract 1" ,
297351 defaultInstantiateFee ,
352+ {
353+ funds : funds ,
354+ admin : makeRandomAddress ( ) ,
355+ } ,
298356 ) ;
299357
300358 client . disconnect ( ) ;
@@ -346,42 +404,65 @@ describe("SigningCosmWasmClient", () => {
346404 client . disconnect ( ) ;
347405 } ) ;
348406
349- it ( "works with Amino JSON signing " , async ( ) => {
407+ it ( "works with Amino JSON signer " , async ( ) => {
350408 pendingWithoutWasmd ( ) ;
351- pending ( "wasmd 0.50 does not work with Amino JSON signing" ) ;
352- const aminoJsonWallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , {
409+ const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , {
353410 prefix : wasmd . prefix ,
354411 } ) ;
355412 const client = await SigningCosmWasmClient . connectWithSigner (
356413 wasmd . endpoint ,
357- aminoJsonWallet ,
414+ wallet ,
358415 defaultSigningClientOptions ,
359416 ) ;
360417 const { codeId } = await client . upload ( alice . address0 , getHackatom ( ) . data , defaultUploadFee ) ;
361418 const funds = [ coin ( 1234 , "ucosm" ) , coin ( 321 , "ustake" ) ] ;
362- const salt = Random . getBytes ( 64 ) ;
363419 const msg = {
364420 verifier : alice . address0 ,
365421 beneficiary : makeRandomAddress ( ) ,
366422 } ;
367423
368- const { contractAddress } = await client . instantiate2 (
369- alice . address0 ,
370- codeId ,
371- salt ,
372- msg ,
373- "My cool label--" ,
374- defaultInstantiateFee ,
375- {
376- memo : "Let's see if the memo is used" ,
377- funds : funds ,
378- } ,
379- ) ;
424+ // Without admin
425+ {
426+ const salt = Random . getBytes ( 64 ) ;
427+ const { contractAddress } = await client . instantiate2 (
428+ alice . address0 ,
429+ codeId ,
430+ salt ,
431+ msg ,
432+ "My cool label--" ,
433+ defaultInstantiateFee ,
434+ {
435+ memo : "Let's see if the memo is used" ,
436+ funds : funds ,
437+ } ,
438+ ) ;
439+ const ucosmBalance = await client . getBalance ( contractAddress , "ucosm" ) ;
440+ const ustakeBalance = await client . getBalance ( contractAddress , "ustake" ) ;
441+ expect ( ucosmBalance ) . toEqual ( funds [ 0 ] ) ;
442+ expect ( ustakeBalance ) . toEqual ( funds [ 1 ] ) ;
443+ }
380444
381- const ucosmBalance = await client . getBalance ( contractAddress , "ucosm" ) ;
382- const ustakeBalance = await client . getBalance ( contractAddress , "ustake" ) ;
383- expect ( ucosmBalance ) . toEqual ( funds [ 0 ] ) ;
384- expect ( ustakeBalance ) . toEqual ( funds [ 1 ] ) ;
445+ // With admin
446+ {
447+ const salt = Random . getBytes ( 64 ) ;
448+ const { contractAddress } = await client . instantiate2 (
449+ alice . address0 ,
450+ codeId ,
451+ salt ,
452+ msg ,
453+ "My cool label--" ,
454+ defaultInstantiateFee ,
455+ {
456+ memo : "Let's see if the memo is used" ,
457+ funds : funds ,
458+ admin : makeRandomAddress ( ) ,
459+ } ,
460+ ) ;
461+ const ucosmBalance = await client . getBalance ( contractAddress , "ucosm" ) ;
462+ const ustakeBalance = await client . getBalance ( contractAddress , "ustake" ) ;
463+ expect ( ucosmBalance ) . toEqual ( funds [ 0 ] ) ;
464+ expect ( ustakeBalance ) . toEqual ( funds [ 1 ] ) ;
465+ }
385466
386467 client . disconnect ( ) ;
387468 } ) ;
@@ -528,9 +609,8 @@ describe("SigningCosmWasmClient", () => {
528609 client . disconnect ( ) ;
529610 } ) ;
530611
531- it ( "works with legacy Amino signer" , async ( ) => {
612+ it ( "works with Amino JSON signer" , async ( ) => {
532613 pendingWithoutWasmd ( ) ;
533- pending ( "wasmd 0.50 does not work with Amino JSON signing" ) ;
534614 const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
535615 const client = await SigningCosmWasmClient . connectWithSigner (
536616 wasmd . endpoint ,
@@ -632,9 +712,8 @@ describe("SigningCosmWasmClient", () => {
632712 client . disconnect ( ) ;
633713 } ) ;
634714
635- it ( "works with legacy Amino signer" , async ( ) => {
715+ it ( "works with Amino JSON signer" , async ( ) => {
636716 pendingWithoutWasmd ( ) ;
637- pending ( "wasmd 0.50 does not work with Amino JSON signing" ) ;
638717 const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
639718 const client = await SigningCosmWasmClient . connectWithSigner (
640719 wasmd . endpoint ,
@@ -794,7 +873,7 @@ describe("SigningCosmWasmClient", () => {
794873 client . disconnect ( ) ;
795874 } ) ;
796875
797- it ( "works with legacy Amino signer" , async ( ) => {
876+ it ( "works with Amino JSON signer" , async ( ) => {
798877 pendingWithoutWasmd ( ) ;
799878 const wallet = await Secp256k1HdWallet . fromMnemonic ( alice . mnemonic , { prefix : wasmd . prefix } ) ;
800879 const client = await SigningCosmWasmClient . connectWithSigner (
0 commit comments