Giter Site home page Giter Site logo

sdk-csharp's Introduction

SDK-CSharp

C# TPP SDK for interacting with Token Platform.

Requirements

On Windows

There are no prerequisites for Windows.

On Linux and OSX

Install Mono from here.

`Mono` is an open source implementation of Microsoft's .NET Framework. It brings the .NET framework to non-Windows envrionments like Linux and OSX.

Build

On OSX

Make sure you have ruby and dotnet-sdk installed.

Build the protobuf classes if you haven't:

ruby build_proto.rb

To build the solution:

dotnet build

To run the tests:

dotnet test

Using the SDK

To use the SDK, add the Nuget package as a dependency to your project file:

<ItemGroup>
    <PackageReference Include="Token.SDK.Net" Version="2.0.0-beta2" />
</ItemGroup>

sdk-csharp's People

Contributors

drobinson123 avatar gianluca-token avatar nikanka-token avatar prateek-gupta1 avatar priyanshu-ap avatar sam-token avatar sibinlu avatar vanika-ap avatar yuhan-token avatar yusuf-aps avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-csharp's Issues

Transfer destination issue

Hi,

Not sure if this is something I should report here but like 2 days ago I was retrieving transfer destination list just fine, now it returns exception: "One or more errors occurred. (Status(StatusCode=Unknown, Detail=""))".

var wiselyMember = _generateTokenClient.Generate().GetMemberBlocking(DiInstaller.BomadMemberId);

var memberToAccess = wiselyMember.ForAccessToken("ta:9eMMVJmCJLZD9fFqxEpuqDXX73hV4y8jnGwryE8QTBHt:5zKtXEAq");

var accounts = memberToAccess.GetAccountsBlocking();
var transferEndpoint = memberToAccess.ResolveTransferDestinationsBlocking(accounts[0].Id()); // <== AccountId is returned from .Id()

Thanks for your help.

Building Protos on windows

The ruby file doesnt seem to work on windows. I have written a powershell version

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$tokenProtosVersion = "1.1.84"
$rpcProtosVersion = "1.1.38"

Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
    param([string]$zipfile, [string]$outpath, [string] $filterPath,  [string] $filter)

    $temp = "temp"

    write-host "Extract $zipfile to $temp"
    [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $temp)


    New-Item -ItemType Directory -Force -Path $outpath
    #write-host "Copy-Item $temp$filterPath/$filter $outpath"
    Copy-Item $temp$filterPath/$filter $outpath
    
    Remove-Item $temp -Force -Recurse
}


function DownloadFile([string] $url, [string] $output)
{
    write-host "`Downloading $url to $output ..."
    
    $wc = New-Object System.Net.WebClient
    $wc.DownloadFile($url, $output)
    
    write-host "Download complete"
}

function DownloadPackage([string] $path, [string] $name, [string] $type, [string] $version)
{
    $file = "$name-$type-$version.jar"

    $url = "https://token.jfrog.io/token/libs-release/$path/$name-$type/$version/$file"
    $output = "$PSScriptRoot\$file"

    DownloadFile -url $url -output $output
    return $file
}


function FetchProtos{

    Remove-Item protos/common/*.proto
    Remove-Item protos/external -Force -Recurse

    $file = DownloadPackage "io/token/proto" "tokenio-proto" "external" $tokenProtosVersion
    write-host "unzipping $file"
    Unzip $file "protos/external/gateway" "/gateway" "*.proto"
    Remove-Item $file

    $file = DownloadPackage "io/token/proto" "tokenio-proto" "common" $tokenProtosVersion
    write-host "unzipping $file"
    Unzip $file "protos/common" "" "*.proto"
    Unzip $file "protos/common/google/api" "/google/api" "*.proto"
    Unzip $file "protos/common/google/protobuf" "/google/protobuf" "*.proto"
    Remove-Item $file

    $file = DownloadPackage "io/token/rpc" "tokenio-rpc" "proto" $rpcProtosVersion
    write-host "unzipping $file"
    Unzip $file "protos/extensions" "/extensions" "*.proto" # /extensions is not defined in the .rb file
    Remove-Item $file
}


function GenerateProtos([string] $pathToProtos, [string] $outDir)
{
    $src = "$PSScriptRoot\protos"
    $protocDir = "tools\windows_x64"
    $protoc = "$protocDir\protoc.exe"
    $plugin = "$protocDir\grpc_csharp_plugin.exe"

    
    New-Item -ItemType Directory -Force -Path $outDir
    
    $files = Get-ChildItem "$src\$pathToProtos"

    foreach($protoFile in $files){
        write-host "Building $protoFile"
        $command = "$protoc --plugin=protoc-gen-grpc=$plugin --csharp_out=$outDir --grpc_out=$outDir -I=$src\common -I=$src\external -I=$src -I=$src\$pathToProtos $protoFile"        
        #write-host $command
        Invoke-Expression $command
    }


    Write-Host "built"
}


# download an extract protos from the jar files
FetchProtos

$dir = "$PSScriptRoot\sdk\generated"
Remove-Item $dir -Force -Recurse

write-host "Building protos into $dir"

#Compile the proto files to c#
GenerateProtos "common" $dir
GenerateProtos "common/google/api" $dir
GenerateProtos "external/gateway" $dir
GenerateProtos "extensions" $dir

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.