-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/safe-sign-text' into tmp/20241101
- Loading branch information
Showing
41 changed files
with
2,451 additions
and
313 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
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,39 @@ | ||
import { createSafeService } from '@/background/utils/safe'; | ||
import { poll } from '@/utils/poll'; | ||
|
||
export const gnosisController = { | ||
watchMessage: async ({ | ||
address, | ||
chainId, | ||
safeMessageHash, | ||
pollingInterval = 10000, | ||
}: { | ||
address: string; | ||
chainId: number; | ||
safeMessageHash: string; | ||
pollingInterval?: number; | ||
}) => { | ||
const safe = await createSafeService({ | ||
address, | ||
networkId: String(chainId), | ||
}); | ||
const threshold = await safe.getThreshold(); | ||
|
||
// todo: manual destroy | ||
return new Promise((resolve, reject) => { | ||
poll( | ||
async ({ unpoll }) => { | ||
const res = await safe.apiKit.getMessage(safeMessageHash); | ||
if (res.confirmations.length >= threshold) { | ||
resolve(res.preparedSignature); | ||
unpoll(); | ||
} | ||
}, | ||
{ | ||
interval: pollingInterval, | ||
emitOnBegin: true, | ||
} | ||
); | ||
}); | ||
}, | ||
}; |
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
Oops, something went wrong.