import axios from "axios" ; const BASE_URL = "https://safe-relay.staging.gnosisdev.com/api" ; const API_VERSION = "v3" ; async function generateRandomBytes ( randomBytes ) { const byteCount = randomBytes . length ; let randomIntAggregator = 0 ; for ( let index = 0 ; index < byteCount ; index ++ ) { randomIntAggregator += randomBytes [ byteCount - index - 1 ] * Math . pow ( 256 , index ) ; } return randomIntAggregator ; } export async function create ( owners , threshold , randomBytes , baseURL = BASE_URL ) { try { const randomInt = await generateRandomBytes ( randomBytes ) ; console . log ( { randomInt } ) ; const api = axios . create ( { baseURL : baseURL , } ) ; const response = await api . post ( `/${ API_VERSION }/safes/` , { threshold : threshold , owners : owners , saltNonce : randomInt , } ) ; const { data , status } = response ; console . log ( { data } ) ; console . log ( { status } ) ; const { safe : safeAddress } = data ; return safeAddress ; } catch ( error ) { console . log ( "Error" ) ; console . log ( error . response . data ) ; throw error ; } }