-
Notifications
You must be signed in to change notification settings - Fork 221
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
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Signer } from '@ethersproject/abstract-signer' | ||
import SafeApiKit, { AddSafeDelegateProps } from '@safe-global/api-kit/index' | ||
import chai from 'chai' | ||
import chaiAsPromised from 'chai-as-promised' | ||
import config from '../utils/config' | ||
import { getServiceClient } from '../utils/setupServiceClient' | ||
import { ethers } from 'ethers' | ||
|
||
chai.use(chaiAsPromised) | ||
|
||
let safeApiKit: SafeApiKit | ||
let signer: Signer | ||
|
||
const MESSAGE = 'I am the owner of this safe' | ||
|
||
describe.only('addMessage', () => { | ||
before(async () => { | ||
;({ safeApiKit, signer } = await getServiceClient( | ||
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d' | ||
)) | ||
}) | ||
|
||
it('should fail if safeAddress is empty', async () => { | ||
await chai | ||
.expect( | ||
safeApiKit.addMessage('', { | ||
message: MESSAGE, | ||
signature: '0x' | ||
}) | ||
) | ||
.to.be.rejectedWith('Invalid safeAddress') | ||
}) | ||
|
||
it('should allow to add an offchain message', async () => { | ||
console.log(await signer.getAddress()) | ||
const signature = await signer.signMessage(MESSAGE) | ||
|
||
await chai.expect( | ||
safeApiKit.addMessage('0x9D1E7371852a9baF631Ea115b9815deb97cC3205', { | ||
message: MESSAGE, | ||
signature | ||
}) | ||
).to.be.fulfilled | ||
}) | ||
}) |